#106 exit02 uses strcmp() on unterminated string

System Calls
closed-accepted
mreed
Testcases (113)
5
2007-04-13
2006-12-03
No

ltp/testcases/kernel/syscalls/exit/exit02.c reads 4 bytes from a file into rbuf[], then calls strcmp(rbuf, wbuf). This is causing the test to fail not because it went wrong but because rbuf did not happen to contain a '\0' at rbuf[4].

changing to strncmp() fixed this.

--- ltp-full-20060717/testcases/kernel/syscalls/exit/exit02.c.orig 2006-12-03 06:59:51.000000000 -0800
+++ ltp-full-20060717/testcases/kernel/syscalls/exit/exit02.c 2006-12-03 07:41:11.000000000 -0800
@@ -168,7 +168,7 @@
tst_resm(TFAIL, "exit error: file "
"buffer was not flushed");
rval = 1;
- } else if (strcmp(rbuf, wbuf) != 0) {
+ } else if (strncmp(rbuf, wbuf, len) != 0) {
tst_resm(TFAIL, "exit error: file "
"buffer was not flushed");
rval = 1;

Discussion

  • Robert Williamson

    • assigned_to: nobody --> mreed10
     
  • Subrata Modak

    Subrata Modak - 2007-04-13

    Logged In: YES
    user_id=1737361
    Originator: NO

    Fixed

     
  • Subrata Modak

    Subrata Modak - 2007-04-13
    • status: open --> closed-accepted
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks