summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2013-11-05 16:20:16 +0100
committerDenys Vlasenko <dvlasenk@redhat.com>2013-11-05 16:20:16 +0100
commit1f65c3cd2ac24c6fcc6a8eb3eb88cd6161c25c88 (patch)
tree7ebfd7c1216c3b1b3d01c25e2fb4d37e272f3b2c
parentc4b9214a0fe23f1b1196bdfb5addcba013855cb3 (diff)
downloadstrace-1f65c3cd2ac24c6fcc6a8eb3eb88cd6161c25c88.tar.gz
strace-1f65c3cd2ac24c6fcc6a8eb3eb88cd6161c25c88.tar.bz2
strace-1f65c3cd2ac24c6fcc6a8eb3eb88cd6161c25c88.tar.xz
Truncate arg[0] to int in select decoding.
This matches kernel's behavior. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r--desc.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/desc.c b/desc.c
index 384b147..bbdc087 100644
--- 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);