From: frequent <frequentemail@126.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] syscalls/dup2/dup201.c: buffer overflow detected ***: dup201 terminated
Date: Wed, 11 Sep 2019 11:37:31 +0800 (CST) [thread overview]
Message-ID: <9146674.351f.16d1e65cf38.Coremail.frequentemail@126.com> (raw)
From: Wu,Haiqiang <frequentemail@126.com>
fixes:#570
Signed-off-by: Wu,Haiqiang <frequentemail@126.com>
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 {
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();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190911/e57e12b4/attachment.htm>
next reply other threads:[~2019-09-11 3:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-11 3:37 frequent [this message]
2019-09-11 9:16 ` [LTP] [PATCH] syscalls/dup2/dup201.c: buffer overflow detected ***: dup201 terminated Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9146674.351f.16d1e65cf38.Coremail.frequentemail@126.com \
--to=frequentemail@126.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox