From 6522f132ba865f90ba3bb3a740eff191911e4dba Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Tue, 9 Sep 2014 22:42:12 +0000 Subject: [PATCH] decode_select: fix potential use of an uninitialized variable A pointer to fd_set was used uninitialized when nfds == 0. * desc.c (decode_select): Initialize fds. Reported-by: Zubin Mithra --- desc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/desc.c b/desc.c index 5b8869bc..491e9ba9 100644 --- a/desc.c +++ b/desc.c @@ -314,7 +314,7 @@ decode_select(struct tcb *tcp, long *args, enum bitness_t bitness) { int i, j; int nfds, fdsize; - fd_set *fds; + fd_set *fds = NULL; const char *sep; long arg; @@ -322,10 +322,9 @@ decode_select(struct tcb *tcp, long *args, enum bitness_t bitness) nfds = (int) args[0]; /* Kernel rejects negative nfds, so we don't parse it either. */ - if (nfds < 0) { + if (nfds < 0) nfds = 0; - fds = NULL; - } + /* Beware of select(2^31-1, NULL, NULL, NULL) and similar... */ if (nfds > 1024*1024) nfds = 1024*1024; -- 2.40.0