summaryrefslogtreecommitdiffstats
path: root/lib/socket_wrapper
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2014-05-08 14:04:11 +0200
committerAndreas Schneider <asn@cryptomilk.org>2014-05-09 09:03:33 +0200
commit1f8fe835b51773dc2236c428d2cde905127e4b09 (patch)
tree7e437a90daabbfef26548fc26ca6d894598738cf /lib/socket_wrapper
parent0ba276ebad57d75a769e22414f94acbe8c177d97 (diff)
downloadsamba-1f8fe835b51773dc2236c428d2cde905127e4b09.tar.gz
samba-1f8fe835b51773dc2236c428d2cde905127e4b09.tar.xz
samba-1f8fe835b51773dc2236c428d2cde905127e4b09.zip
swrap: Do not leak memory in swrap_recvmsg_after().
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jakub Hrozek <jhrozek@redhat.com> Reviewed-by: Simo Sorce <idra@samba.org>
Diffstat (limited to 'lib/socket_wrapper')
-rw-r--r--lib/socket_wrapper/socket_wrapper.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c
index c5b1fdf85e..5ed9d9fa73 100644
--- a/lib/socket_wrapper/socket_wrapper.c
+++ b/lib/socket_wrapper/socket_wrapper.c
@@ -3155,7 +3155,7 @@ static int swrap_recvmsg_after(int fd,
{
int saved_errno = errno;
size_t i;
- uint8_t *buf;
+ uint8_t *buf = NULL;
off_t ofs = 0;
size_t avail = 0;
size_t remain;
@@ -3187,7 +3187,7 @@ static int swrap_recvmsg_after(int fd,
/* we capture it as one single packet */
buf = (uint8_t *)malloc(remain);
- if (!buf) {
+ if (buf == NULL) {
/* we just not capture the packet */
errno = saved_errno;
return -1;
@@ -3228,7 +3228,7 @@ static int swrap_recvmsg_after(int fd,
msg->msg_name,
&msg->msg_namelen);
if (rc == -1) {
- return -1;
+ goto done;
}
swrap_dump_packet(si,
@@ -3247,6 +3247,7 @@ static int swrap_recvmsg_after(int fd,
break;
}
+done:
free(buf);
errno = saved_errno;
return 0;