From: Stephen Gallagher Date: Mon, 14 Feb 2011 15:29:49 +0000 (-0500) Subject: Return NULL if tevent_add_fd() is passed a negative fd X-Git-Tag: tevent-0.9.11~668 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d6a41c2723cda59b3cd6ae9a1e77b62f25067663;p=thirdparty%2Fsamba.git Return NULL if tevent_add_fd() is passed a negative fd Autobuild-User: Simo Sorce Autobuild-Date: Mon Feb 14 17:47:03 CET 2011 on sn-devel-104 --- diff --git a/lib/tevent/tevent_fd.c b/lib/tevent/tevent_fd.c index c58e8e1ab18..455961b67c8 100644 --- a/lib/tevent/tevent_fd.c +++ b/lib/tevent/tevent_fd.c @@ -51,6 +51,12 @@ struct tevent_fd *tevent_common_add_fd(struct tevent_context *ev, TALLOC_CTX *me { struct tevent_fd *fde; + /* tevent will crash later on select() if we save + * a negative file descriptor. Better to fail here + * so that consumers will be able to debug it + */ + if (fd < 0) return NULL; + fde = talloc(mem_ctx?mem_ctx:ev, struct tevent_fd); if (!fde) return NULL;