Menu

#107 pipe10 calls strcmp() on unterminated string

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

ltp/testcases/kernel/syscalls/pipe/pipe10.c writes a string to the child. The length written is strlen(wrbuf), thus it does not include the terminating '\0'. The child read(2)s this into rebuf, and then calls strcmp(rebuf, wrbuf). Since rebuf is not properly terminated strcmp() can fail.

It looks like someone tried to fix this by adding a '\0' at the end of the string used to initialize wrbuf, but since the length sent is determined by strlen(3) that makes no difference.

A simple fix is to include the '\0' in the data written to the child. Patch below.

Discussion

  • Nicolas Dade

    Nicolas Dade - 2006-12-04

    patch to fix pipe10.c calling strcmp() on unterminated string

     
  • Robert Williamson

    • assigned_to: nobody --> mreed10
     
  • Subrata Modak

    Subrata Modak - 2007-04-13

    Logged In: YES
    user_id=1737361
    Originator: NO

    Patch Applied and Bug closed.

    Thanks--
    Subrata

     
  • Subrata Modak

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

Log in to post a comment.