Bug in htdig


Zvi Har'El (rl@math.technion.ac.il)
Sat, 5 Sep 1998 00:18:28 +0300 (IDT)


Dear Andrew Scherpbier:

This fixes a bug in the indexOf (char*) function: The search for a substring
must be terminated when its last character reaches the last position of the
data; the faulty code terminates the search only when the first character
reaches the last position! The bug was revealed when indexOf was called to
remove "/../" substrings from a path, in case the path is of the form
"abcd/xx/../yy/". Although logically removed, this substring was found again
because the search doesn't terminate in time, and the result was "abcd" instead
of "abcd/yy/". The problem didn't occur for a path of the form "abcd/xx/../yy",
which was correctly reduced to "abcd/yy".

*** htdig-3.0.8b2/htlib/String.cc.orig Fri Aug 15 08:59:38 1997
--- htdig-3.0.8b2/htlib/String.cc Fri Sep 4 22:20:52 1998
***************
*** 254,260 ****
  {
      int len = strlen(str);
      int i;
! for (i = 0; i < Length; i++)
      {
          if (strncmp(&Data[i], str, len) == 0)
              return i;
--- 254,261 ----
  {
      int len = strlen(str);
      int i;
! /* OLD CODE: for (i = 0; i < Length; i++) */
! for (i = 0; i <= Length-len; i++)
      {
          if (strncmp(&Data[i], str, len) == 0)
              return i;

--
Dr. Zvi Har'El     mailto:rl@math.technion.ac.il     Department of Mathematics
+972-4-8294094(Phone)                Technion - Israel Institute of Technology
+972-4-8324654(FAX)  http://www.math.technion.ac.il/~rl/   Haifa 32000, ISRAEL
``If you can't say somethin' nice, don't say nothin' at all.''--Thumper (1942)



This archive was generated by hypermail 2.0b3 on Sat Jan 02 1999 - 16:27:41 PST