diff options
author | Michael Adam <obnox@samba.org> | 2016-10-25 13:41:29 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2016-10-25 14:55:04 +0200 |
commit | 3b39c88b138f88bffc7d71572a9c6a83e54a03c9 (patch) | |
tree | 21618c8eadaf741fabf4fa362c5340d36c16a8fd /src | |
parent | d4cdce1ce3042746661ce93f2be2425dd9810204 (diff) | |
download | socket_wrapper-3b39c88b138f88bffc7d71572a9c6a83e54a03c9.tar.gz socket_wrapper-3b39c88b138f88bffc7d71572a9c6a83e54a03c9.tar.xz socket_wrapper-3b39c88b138f88bffc7d71572a9c6a83e54a03c9.zip |
swrap: fix use-after-free in swrap_close
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/socket_wrapper.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index 82d27e5..8ac838b 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -5351,17 +5351,19 @@ static int swrap_close(int fd) { struct socket_info_fd *fi = find_socket_info_fd(fd); struct socket_info *si = NULL; + int si_index; int ret; if (fi == NULL) { return libc_close(fd); } - si = &sockets[fi->si_index]; + si_index = fi->si_index; SWRAP_DLIST_REMOVE(socket_fds, fi); free(fi); + si = &sockets[si_index]; si->refcount--; if (si->refcount > 0) { @@ -5385,7 +5387,7 @@ static int swrap_close(int fd) } si->next_free = first_free; - first_free = fi->si_index; + first_free = si_index; return ret; } |