]> granicus.if.org Git - strace/commitdiff
Truncate arg[0] to int in select decoding.
authorDenys Vlasenko <dvlasenk@redhat.com>
Tue, 5 Nov 2013 15:20:16 +0000 (16:20 +0100)
committerDenys Vlasenko <dvlasenk@redhat.com>
Tue, 5 Nov 2013 15:20:16 +0000 (16:20 +0100)
This matches kernel's behavior.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
desc.c

diff --git a/desc.c b/desc.c
index 384b1472031112dbeb2b37dd0b510922d12244c7..bbdc0872ae086aea0401fcb6fd3e890ed6c52c8c 100644 (file)
--- a/desc.c
+++ b/desc.c
@@ -481,16 +481,17 @@ static int
 decode_select(struct tcb *tcp, long *args, enum bitness_t bitness)
 {
        int i, j;
-       unsigned nfds, fdsize;
+       int nfds, fdsize;
        fd_set *fds;
        const char *sep;
        long arg;
 
-       fdsize = args[0];
+       /* Kernel truncates arg[0] to int, we do the same */
+       fdsize = (int)args[0];
        /* Beware of select(2^31-1, NULL, NULL, NULL) and similar... */
-       if (args[0] > 1024*1024)
+       if (fdsize > 1024*1024)
                fdsize = 1024*1024;
-       if (args[0] < 0)
+       if (fdsize < 0)
                fdsize = 0;
        nfds = fdsize;
        fdsize = (((fdsize + 7) / 8) + sizeof(long)-1) & -sizeof(long);