summaryrefslogtreecommitdiff
path: root/source4/lib/socket_wrapper
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-09-16 17:57:50 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:18:52 -0500
commit3d6cdc9e97d13052c3e15d72a6e550e9c10319a1 (patch)
tree392ea43f187acfccb622bfa5b3933fddb67a4b75 /source4/lib/socket_wrapper
parent9bda2c3ff27ee5c692bc4b1f19e2ed0f53e30860 (diff)
downloadsamba-3d6cdc9e97d13052c3e15d72a6e550e9c10319a1.tar.gz
samba-3d6cdc9e97d13052c3e15d72a6e550e9c10319a1.tar.bz2
samba-3d6cdc9e97d13052c3e15d72a6e550e9c10319a1.zip
r18586: fixed a potential fd and memory leak in the socket_wrapper code
(This used to be commit 6d53f2f5bc3a008f957be9e32df6830e1e29e8ed)
Diffstat (limited to 'source4/lib/socket_wrapper')
-rw-r--r--source4/lib/socket_wrapper/socket_wrapper.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/source4/lib/socket_wrapper/socket_wrapper.c b/source4/lib/socket_wrapper/socket_wrapper.c
index 4fecc90980..fe0b4dfe76 100644
--- a/source4/lib/socket_wrapper/socket_wrapper.c
+++ b/source4/lib/socket_wrapper/socket_wrapper.c
@@ -494,7 +494,10 @@ _PUBLIC_ int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
ret = sockaddr_convert_from_un(parent_si, &un_addr, un_addrlen,
parent_si->family, addr, addrlen);
- if (ret == -1) return ret;
+ if (ret == -1) {
+ close(fd);
+ return ret;
+ }
child_si = malloc(sizeof(struct socket_info));
memset(child_si, 0, sizeof(*child_si));
@@ -506,11 +509,19 @@ _PUBLIC_ int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
child_si->bound = 1;
ret = real_getsockname(fd, (struct sockaddr *)&un_my_addr, &un_my_addrlen);
- if (ret == -1) return ret;
+ if (ret == -1) {
+ free(child_si);
+ close(fd);
+ return ret;
+ }
ret = sockaddr_convert_from_un(child_si, &un_my_addr, un_my_addrlen,
child_si->family, &my_addr, &my_addrlen);
- if (ret == -1) return ret;
+ if (ret == -1) {
+ free(child_si);
+ close(fd);
+ return ret;
+ }
child_si->myname_len = my_addrlen;
child_si->myname = sockaddr_dup(&my_addr, my_addrlen);