[SCM] Socket Wrapper Repository - branch master updated

Andreas Schneider asn at samba.org
Wed Feb 24 07:29:52 UTC 2016


The branch, master has been updated
       via  1f9ea96 swrap: Use calloc() instead of malloc and memset
       via  ad9e56e swrap: Allow to open NETLINK sockets when loaded
      from  c7c45b0 tests: Add test for ephemeral port binding in listen()

https://git.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 1f9ea967f81938a86fd120f59daaa01f055cdb48
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Feb 23 11:22:58 2016 +0100

    swrap: Use calloc() instead of malloc and memset
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit ad9e56e2b695cdba7000829c43d7c444a227fe4d
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Nov 5 14:44:26 2015 +0100

    swrap: Allow to open NETLINK sockets when loaded
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 src/socket_wrapper.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 9ba212b..fc9116b 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -1855,11 +1855,10 @@ static uint8_t *swrap_pcap_packet_init(struct timeval *tval,
 		alloc_len = SWRAP_PACKET_MIN_ALLOC;
 	}
 
-	base = (uint8_t *)malloc(alloc_len);
+	base = (uint8_t *)calloc(1, alloc_len);
 	if (base == NULL) {
 		return NULL;
 	}
-	memset(base, 0x0, alloc_len);
 
 	buf = base;
 
@@ -2384,6 +2383,7 @@ static int swrap_socket(int family, int type, int protocol)
 	case AF_INET6:
 #endif
 		break;
+	case AF_NETLINK:
 	case AF_UNIX:
 		return libc_socket(family, type, protocol);
 	default:
@@ -2435,8 +2435,7 @@ static int swrap_socket(int family, int type, int protocol)
 		swrap_remove_stale(fd);
 	}
 
-	si = (struct socket_info *)malloc(sizeof(struct socket_info));
-	memset(si, 0, sizeof(struct socket_info));
+	si = (struct socket_info *)calloc(1, sizeof(struct socket_info));
 	if (si == NULL) {
 		errno = ENOMEM;
 		return -1;
@@ -2630,8 +2629,12 @@ static int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
 		return ret;
 	}
 
-	child_si = (struct socket_info *)malloc(sizeof(struct socket_info));
-	memset(child_si, 0, sizeof(struct socket_info));
+	child_si = (struct socket_info *)calloc(1, sizeof(struct socket_info));
+	if (child_si == NULL) {
+		close(fd);
+		errno = ENOMEM;
+		return -1;
+	}
 
 	child_fi = (struct socket_info_fd *)calloc(1, sizeof(struct socket_info_fd));
 	if (child_fi == NULL) {


-- 
Socket Wrapper Repository



More information about the samba-cvs mailing list