]> granicus.if.org Git - strace/commitdiff
decode_select: fix potential use of an uninitialized variable
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 9 Sep 2014 22:42:12 +0000 (22:42 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 9 Sep 2014 22:51:05 +0000 (22:51 +0000)
A pointer to fd_set was used uninitialized when nfds == 0.

* desc.c (decode_select): Initialize fds.

Reported-by: Zubin Mithra <zubin.mithra@gmail.com>
desc.c

diff --git a/desc.c b/desc.c
index 5b8869bcf92e426bfd85b2410cf58ff449f2291b..491e9ba96b8cb24e801d88708373668d380ef1dc 100644 (file)
--- 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;