Looking at this some more I've found a bug in config.c. This code is bad:

  /* Search the first " */
  for (i = 0; i <= strlen (file_content) && file_content[i] != '"'; i++);
  file_content += i + 1;

  /* Search the last " */
  for (j = strlen (file_content); j >= 1 && file_content[j - 1] != '"'; j--);

  if (j == 0)
    {
      fprintf (stderr, "Error parsing options, check configuration file.\n");
      exit (EXIT_FAILURE);
    }

  /* Remove the first spaces if they exists */
  while (file_content[0] == ' ')
    file_content++;

  if (strlen (file_content) > 2)
    {
      result = strndup (file_content, j - 2);
      return result;
    }

  return NULL;

since it calculates j based on file_content and then adjusts file_content. 
Wouldn't it be better to find the first ", then skip leading spaces by moving 
file_content. Then you can find the last " and then skip trailing spaces.

Cheers,
Tim.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to