]> granicus.if.org Git - strace/commitdiff
Add a test for the latest select decoding fix
authorDr. David Alan Gilbert <dave@treblig.org>
Tue, 5 Nov 2013 23:28:56 +0000 (23:28 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 5 Nov 2013 23:35:56 +0000 (23:35 +0000)
* test/select.c (main): Add a test for nfds larger than FD_SETSIZE.

test/select.c

index aee9f4394dd4f93105a44dedd0f40caa418f0407..0810fff7e3ff13a5176d138aa50a6665d5359be4 100644 (file)
@@ -11,13 +11,24 @@ char buffer[1024*1024*2];
 int main()
 {
        fd_set rds;
+       struct timeval timeout;
+
        FD_ZERO(&rds);
        FD_SET(2, &rds);
        /* Start with a nice simple select */
        select(3, &rds, &rds, &rds, NULL);
+
        /* Now the crash case that trinity found, negative nfds
         * but with a pointer to a large chunk of valid memory.
         */
+       FD_ZERO((fd_set*)buffer);
+       FD_SET(2,(fd_set*)buffer);
        select(-1, (fd_set *)buffer, NULL, NULL, NULL);
+
+       /* Another variant, with nfds exceeding allowed limit. */
+       timeout.tv_sec = 0;
+       timeout.tv_usec = 100;
+       select(FD_SETSIZE + 1, (fd_set *)buffer, NULL, NULL, &timeout);
+
        return 0;
 }