bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

two bugs in id-utils


From: Paul Fox
Subject: two bugs in id-utils
Date: Fri, 11 Jul 2003 12:35:02 -0400

hi --  i'm using the id-utils package version 3.2.

bug #1:

when the id-searching commands in the id-utils package (i'm running
version 3.2) search for the ID file, they attempt to search for
the file in the current directory, and then all parent directories
up to root.  the logic for this is broken.


the logic that does this, from libidu/idfile.c, looks like:
...
  if (stat ("/", &rootb) != 0)
    return NULL;
  do
    {
      strcpy (buf, "../");
      buf += 3;
      strcpy (buf, arg);
      if (stat (file_name_buffer, &statb) == 0)
        return file_name_buffer;
      *buf = '\0';
      if (stat (file_name_buffer, &statb) != 0)
        return NULL;
    }
  while (!((statb.st_ino == rootb.st_ino) || 
           (statb.st_dev == rootb.st_dev)));
  return NULL;
}

i believe the termination condition on the above loop is incorrect.
it should read:

  if (stat ("/", &rootb) != 0)
    return NULL;
  do
    {
      strcpy (buf, "../");
      buf += 3;
      strcpy (buf, arg);
      if (stat (file_name_buffer, &statb) == 0)
        return file_name_buffer;
      *buf = '\0';
      if (stat (file_name_buffer, &statb) != 0)
        return NULL;
    }
  while (!((statb.st_ino == rootb.st_ino) &&
           (statb.st_dev == rootb.st_dev)));
  return NULL;
}


bug #2:

when invoked with no arguments, the mkid command should generate
an index for the current directory.  it dumps core.  the code that
handles this case (from src/mkid.c) is:
  if (argc == 0)
    {
      static char *dot = (char *) ".";
      argc = 1;
      argv = ˙
    }

strtok() is run on this string later on, and causes the SEGV.  one
possible fix is:
  if (argc == 0)
    {
      static char *dot;
      dot = strdup(".");
      argc = 1;
      argv = ˙
    }


thanks,
paul
=---------------------
 paul fox, address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]