#30 lseek09 uses unitialized variable

System Calls
closed-fixed
nobody
Testcases (27)
5
2007-07-09
2007-07-07
Helge Deller
No

The testcase lseek09 reads 4 bytes out of a file into a char array, which hasn't been initialized before. The problem is, that the read() syscall only reads the given number of characters (4) but does not add a trailing zero (\0) character. Since the array wasn't zero-initialized before, the 5th character is undefined and (at least on the hppa/parisc architecture) non-zero.
The testcase compares then the read-in string (4 chars + some undefined characters) to the fixed string "defg" with strcmp() and strcmp() fails since the 5th caracter is non-zero.

Simple one-liner patch attached.

Helge

Discussion

  • Helge Deller
    Helge Deller
    2007-07-07

    patch for lseek09

     
    Attachments
  • Subrata Modak
    Subrata Modak
    2007-07-09

    • status: open --> closed-fixed
     
  • Subrata Modak
    Subrata Modak
    2007-07-09

    Logged In: YES
    user_id=1737361
    Originator: NO

    Thanks. This has been applied and updated.
    Regards--
    Subrata