From: Dmitry V. Levin Date: Tue, 9 Sep 2014 22:42:12 +0000 (+0000) Subject: decode_select: fix potential use of an uninitialized variable X-Git-Tag: v4.10~397 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6522f132ba865f90ba3bb3a740eff191911e4dba;p=strace 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 --- 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;