On 20 Mar 2009 at 13:45, Mike Christie wrote:

> Since I am always messing up on string functions I wanted to send this 
> to list to make sure it is right.

Hi Mike!

The best way to finally understand those string finctions is trying to 
them for yourself (just for an exercise). Automatic variables have random 
(undeterminable) content, but for strings you don't have to fill the entire 
variable with zeroes; just putting a zero byte at the start of it should do 
(foo[0] = '\0'). True C programmers are proud to save a few CPU (and memory) 
cycles ;-)

> The filename buf is set up in the function a little bit before diff cut 
> it off like this:
> fwparam_ppc_boot_info()
> {
>       char filename[FILENAMESZ];
> so from what I can tell it is not initialized and could be filled with 
> junk. When we then call strlcat, strlcat could detect a bogus string in 
> there and cat on the end of that. This patch clears the buffer to avoid 
> that.

Specifically instead of:
+       memset(filename, 0, FILENAMESZ);
        strlcat(filename, DT_TOP, FILENAMESZ);

You might consider strncpy(filename, DT_TOP, FILENAMESZ).


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 
For more options, visit this group at http://groups.google.com/group/open-iscsi

Reply via email to