diff mbox series

syscalls/dup2/dup201.c: buffer overflow detected ***: dup201 terminated

Message ID 9146674.351f.16d1e65cf38.Coremail.frequentemail@126.com
State Changes Requested
Headers show
Series syscalls/dup2/dup201.c: buffer overflow detected ***: dup201 terminated | expand

Commit Message

Wu,Haiqiang Sept. 11, 2019, 3:37 a.m. UTC
From: Wu,Haiqiang <frequentemail@126.com>


fixes:#570


Signed-off-by: Wu,Haiqiang <frequentemail@126.com>




        int *ofd;
@@ -86,22 +83,19 @@ struct test_case_t {
        void (*setupfunc) ();
 } TC[] = {
        /* First fd argument is less than 0 - EBADF */
-       {
-       &badfd, &goodfd, EBADF, NULL},
-           /* First fd argument is getdtablesize() - EBADF */
-       {
-       &maxfd, &goodfd, EBADF, NULL},
-           /* Second fd argument is less than 0 - EBADF */
-       {
-       &mystdout, &badfd, EBADF, NULL},
-           /* Second fd argument is getdtablesize() - EBADF */
-       {
-&mystdout, &maxfd, EBADF, NULL},};
+       {&badfd, &goodfd, EBADF, NULL},
+       /* First fd argument is getdtablesize() - EBADF */
+       {&maxfd, &goodfd, EBADF, NULL},
+       /* Second fd argument is less than 0 - EBADF */
+       {&mystdout, &badfd, EBADF, NULL},
+       /* Second fd argument is getdtablesize() - EBADF */
+       {&mystdout, &maxfd, EBADF, NULL},
+};


 int main(int ac, char **av)
 {
        int lc;
-       int i, j;
+       int i;


        tst_parse_opts(ac, av, NULL, NULL);


@@ -137,12 +131,6 @@ int main(int ac, char **av)
                                         strerror(TC[i].error));
                        }
                }
-               /* cleanup things in case we are looping */
-               for (j = fd1; j < maxfd; j++) {
-                       sprintf(fname, "dup201.%d.%d", j, mypid);
-                       (void)close(j);
-                       (void)unlink(fname);
-               }
        }
        cleanup();


@@ -163,7 +151,6 @@ void setup(void)


        /* get some test specific values */
        maxfd = getdtablesize();
-       mypid = getpid();
 }


 /*
@@ -172,6 +159,5 @@ void setup(void)
  */
 void cleanup(void)
 {
-
        tst_rmdir();
 }

Comments

Cyril Hrubis Sept. 11, 2019, 9:16 a.m. UTC | #1
Hi!
I've tried to apply the patch but it looks like it has been mangled by
your email client. The patch does not apply and git complains about
incorrect format.

There is some information on email clients and how to make sure they
send the patches in a correct way here:

https://www.kernel.org/doc/html/v4.17/process/email-clients.html

Also the best way is just to learn to use 'git send-email' which works
quite nicely once you learn to use it.
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/dup2/dup201.c b/testcases/kernel/syscalls/dup2/dup201.c
index 4507ac1..762ad86 100644
--- a/testcases/kernel/syscalls/dup2/dup201.c
+++ b/testcases/kernel/syscalls/dup2/dup201.c
@@ -75,9 +75,6 @@  int maxfd;
 int goodfd = 5;
 int badfd = -1;
 int mystdout = 0;
-int fd, fd1;
-int mypid;
-char fname[20];


 struct test_case_t {