Skip to content

Commit 9109964

Browse files
committed
pread03: Remove unused and buggy test_dir[100]
The test_dir is unused by the test and the sprintf() may have caused buffer overflow in the case that the test temporary directory was over 100 chars. Fixes #154. Signed-off-by: Cyril Hrubis <[email protected]>
1 parent 2854c5b commit 9109964

File tree

1 file changed

+0
-11
lines changed

1 file changed

+0
-11
lines changed

testcases/kernel/syscalls/pread/pread03.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ char *TCID = "pread03";
8888
int TST_TOTAL = 1;
8989

9090
char *read_buf[NBUFS]; /* buffer to hold data read from file */
91-
char test_dir[100];
9291
int fd1;
9392

9493
void setup(); /* Main setup function of test */
@@ -149,8 +148,6 @@ int main(int ac, char **av)
149148
*/
150149
void setup(void)
151150
{
152-
char *cur_dir = NULL;
153-
154151
tst_sig(FORK, DEF_HANDLER, cleanup);
155152

156153
TEST_PAUSE;
@@ -160,13 +157,6 @@ void setup(void)
160157

161158
tst_tmpdir();
162159

163-
/* get the currect directory name */
164-
if ((cur_dir = getcwd(cur_dir, 0)) == NULL) {
165-
tst_brkm(TBROK, cleanup, "Couldn't get current directory name");
166-
}
167-
168-
sprintf(test_dir, "%s.%d", cur_dir, getpid());
169-
170160
/*
171161
* create a temporary directory
172162
*/
@@ -181,7 +171,6 @@ void setup(void)
181171
tst_brkm(TBROK, cleanup, "open() on %s Failed, errno=%d : %s",
182172
PREAD_TEMPDIR, errno, strerror(errno));
183173
}
184-
185174
}
186175

187176
/*

0 commit comments

Comments
 (0)