On 28 Jan 2009 at 17:34, Mike Christie wrote:

>                         strncat(dev_dir, dent->d_name, FILENAMESZ);

Hi,

once again: The third argument of strncpy() counts the bytes to be added, not 
the 
bytes that are already there, so the code may not do what some of you seem to 
expect!

The alternatives are ugly to implement, like this:
        d = snprintf(cp, cap, "%s", string_of_unknown_lenght);
#ifdef  C99_LIBRARY
        if ( d > cap )
                d = cap;
#else
        if ( d > 0 )
#endif
                cp += d, cap -= d;

("cp" being the write position, "cap" the remaining capacity)

Regards,
Ulrich


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to open-iscsi@googlegroups.com
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/open-iscsi
-~----------~----~----~----~------~----~------~--~---

Reply via email to