According to Gilles Detillieux:
> According to Neil Kohl:
> > I'm running htdig 3.1.6 on Solaris 7/sparc. 
> > 
> > I was trying to build a custom synonym database with htfuzzy and it
> > kept segfaulting and dumping core. I could successfully rebuild the
> > synonyms.db from the distribution so I figured there was something
> > wrong with my synonyms file.
> > 
> > Sure enough, there was one term that didn't have any synonyms - it
> > was a single word on a line by itself.
> > 
> > Just putting this out to the list in case someone runs into similar
> > problems in the future, and as a suggestion for a mod to htfuzzy:
> > graceful handling of bad lines in the synonyms file.
> 
> [Suspending lurk mode]
> 
> Thanks for the report!  Here's the fix, which will be in this Sunday's
> snapshot.  You didn't include a stack backtrace, so I can only speculate
> that the segfault occurred in Database::Put(), which seems like the
> only plausible explanation.  Actually, looking into it a bit further,
> it seems there's a problem in String::append(char *, int) as well,
> in that it doesn't check for negative lengths.  Database::Put() calls
> String::append(), so that may be the source of the problem.  I'd still
> appreciate a stack backtrace to confirm where the problem occurred.
> I'd like to close as many holes as I can before 3.1.6 is released.

OK, I did a simple test and reproduced the problem to get a backtrace on
my system (Red Hat 4.2).  Presumably the failure is the same on yours.
The segfault was in memcpy, but the stack was too messed up to give more
details.  I'd assume it was the call to memcpy() from String::append()
that did it.  Before applying the patch to htfuzzy/Synonym.cc, which
I just posted, I tried the patch below, and htfuzzy synonyms ran to
completion without any difficulty.  I've committed both patches to CVS,
for added safety.  Please let me know if either of the patches causes
any problems.  Thanks.


Tue Nov 20 17:13:27 2001  Gilles Detillieux  <[EMAIL PROTECTED]>

        * htlib/String.cc (String, append, sub): Added checks for negative
        lengths or start position to make code more fault-tolerant.

Index: htlib/String.cc
===================================================================
RCS file: /cvsroot/htdig/htdig/htlib/String.cc,v
retrieving revision 1.16.2.5
diff -u -p -r1.16.2.5 String.cc
--- htlib/String.cc     2001/07/05 16:26:35     1.16.2.5
+++ htlib/String.cc     2001/11/20 23:12:34
@@ -61,7 +61,7 @@ String::String(char *s, int len)
 {
     Allocated = 0;
     Length = 0;
-    if (s && len != 0)
+    if (s && len > 0)
        copy(s, len, len);
 }
 
@@ -143,7 +143,7 @@ void String::append(char *s)
 
 void String::append(char *s, int slen)
 {
-    if (!s || !slen)
+    if (!s || slen <= 0)
        return;
 
 //    if ( slen == 1 ) 
@@ -258,7 +258,7 @@ int String::as_integer(int def)
 
 String String::sub(int start, int len) const
 {
-    if (start > Length)
+    if (start > Length || start < 0 || len < 0)
        return 0;
 
     if (len > Length - start)


> [Resuming lurk mode]

-- 
Gilles R. Detillieux              E-mail: <[EMAIL PROTECTED]>
Spinal Cord Research Centre       WWW:    http://www.scrc.umanitoba.ca/~grdetil
Dept. Physiology, U. of Manitoba  Phone:  (204)789-3766
Winnipeg, MB  R3E 3J7  (Canada)   Fax:    (204)789-3930

_______________________________________________
htdig-general mailing list <[EMAIL PROTECTED]>
To unsubscribe, send a message to <[EMAIL PROTECTED]> with a 
subject of unsubscribe
FAQ: http://htdig.sourceforge.net/FAQ.html

Reply via email to