On Monday, January 21, 2013 6:54:33 PM UTC+5:30, manish singh wrote:
>
> Hi Rahul,
>  
> Please see inline
>
> On Mon, Jan 21, 2013 at 12:24 PM, rahul <junky_...@yahoo.co.in<javascript:>
> > wrote:
>
>> Guys,
>>
>>     I see few problems with the function idbm_recinfo_config(). Can 
>> someone please take a look and confirm ?
>>
>> void idbm_recinfo_config(recinfo_t *info, FILE *f)
>> {
>> char name[NAME_MAXVAL];
>> char value[VALUE_MAXVAL];
>>  char *line, *nl, buffer[2048];
>> int line_number = 0;
>> int c = 0, i;
>>
>> fseek(f, 0, SEEK_SET);
>>
>> /* process the config file */
>> do {
>>  line = fgets(buffer, sizeof (buffer), f);
>> line_number++;
>> if (!line)
>>  continue;
>>
>> nl = line + strlen(line) - 1;
>> if (*nl != '\n') {
>>  log_warning("Config file line %d too long.",
>>        line_number);
>> continue;
>>  }
>>
>> Here, if the line is too long that it cannot fit into the buffer, 
>> shouldn't we need to ignore the rest of the line ?
>>  
>>
>  
> I dont see anything worng here fgets reads either till end of line or till 
> given size.
> Refer to link
> http://pubs.opengroup.org/onlinepubs/007904875/functions/fgets.html
>  
> The fgets() function shall read bytes from stream into the array pointed 
> to by s, until n-1 bytes are read, or a <newline> is read and transferred 
> to s, or an end-of-file condition is encountered. The string is then 
> terminated with a null byte.
>

The problem is that if the line is too long (> 2048 chars), then in the 
next iteration it will start reading after 2048 characters which doesn't 
look correct. If the line is longer than 2048 chars we should skip anything 
beyond 2048 on that line.
  

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/open-iscsi/-/y71BVD6kyMYJ.
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?hl=en.

Reply via email to