Re: [PATCH] don't expect inode name to be NUL-terminated (avoid read overrun)

2010-09-15 Thread Jim Meyering
Jeff Garzik wrote: On 09/10/2010 08:55 AM, Jim Meyering wrote: * server/msg.c (msg_get): Copy only name_len bytes, then NUL-terminate, rather than using snprintf to copy up to and including nonexistent NUL. --- valgrind exposed this. The use of snprintf would have been correct if the

Re: [PATCH] don't expect inode name to be NUL-terminated (avoid read overrun)

2010-09-14 Thread Jeff Garzik
On 09/10/2010 08:55 AM, Jim Meyering wrote: * server/msg.c (msg_get): Copy only name_len bytes, then NUL-terminate, rather than using snprintf to copy up to and including nonexistent NUL. --- valgrind exposed this. The use of snprintf would have been correct if the inode name buffer

Re: [PATCH] don't expect inode name to be NUL-terminated (avoid read overrun)

2010-09-10 Thread Colin McCabe
The thing is, snprintf always NULL-terminates its output string, no matter whether the input was NULL-terminated or not. However, I looked at the snprintf man page again and found this description for %s : If no l modifier is present: The const char * argument is expected to be a pointer to