summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2014-01-28 14:10:53 +0100
committerAndreas Schneider <asn@samba.org>2014-01-28 14:11:51 +0100
commitbb4dd1f1733fe80493e3f165f206df675fb32beb (patch)
tree1db492b2b2986d670694d35f2dcb4f1e11a63b44
parent9c03935fc0abb033a32683f5e9d8bd6b2136b8fd (diff)
downloadsocket_wrapper-bb4dd1f1733fe80493e3f165f206df675fb32beb.tar.gz
socket_wrapper-bb4dd1f1733fe80493e3f165f206df675fb32beb.tar.xz
socket_wrapper-bb4dd1f1733fe80493e3f165f206df675fb32beb.zip
src: Handle stale fds in dup() and dup2().
Reviewed-by: Stefan Metzmacher <metze@samba.org>
-rw-r--r--src/socket_wrapper.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 0d74321..353a9a5 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -3934,6 +3934,9 @@ static int swrap_dup(int fd)
return -1;
}
+ /* Make sure we don't have an entry for the fd */
+ swrap_remove_stale(fi->fd);
+
SWRAP_DLIST_ADD(si->fds, fi);
return fi->fd;
}
@@ -3978,6 +3981,9 @@ static int swrap_dup2(int fd, int newfd)
return -1;
}
+ /* Make sure we don't have an entry for the fd */
+ swrap_remove_stale(fi->fd);
+
SWRAP_DLIST_ADD(si->fds, fi);
return fi->fd;
}