[htdig] Patch: prevent hang in Configuration::Add()


Gilles Detillieux (grdetil@scrc.umanitoba.ca)
Mon, 22 Mar 1999 16:44:59 -0600 (CST)


Back on March 11, Dan Dexter had reported a problem with htdig hanging on
one of his documents. The problem turned out to be accented characters
in an unquoted string in a meta tag, which isalnum() on his system choked
on. The program hung in the Configuration::Add() function, which HTML.cc
uses to parse the tag. This patch prevents that hang, on ill behaved
systems:

--- htlib/Configuration.cc.alnumbug Tue Feb 16 23:03:56 1999
+++ htlib/Configuration.cc Fri Mar 19 10:33:28 1999
@@ -62,6 +62,11 @@ void Configuration::Add(char *str)
         name = 0;
         if (!isalpha(*str))
             break;
+ // Some isalnum() implementations don't allow all the letters that
+ // isalpha() does, e.g. accented ones. They're not POSIX.2 compliant
+ // but we won't punish them with an infinite loop...
+ if (!isalnum(*str))
+ break;
         while (isalnum(*str) || *str == '-' || *str == '_')
             name << *str++;
 

-- 
Gilles R. Detillieux              E-mail: <grdetil@scrc.umanitoba.ca>
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
------------------------------------
To unsubscribe from the htdig mailing list, send a message to
htdig@htdig.org containing the single word "unsubscribe" in
the SUBJECT of the message.



This archive was generated by hypermail 2.0b3 on Thu Mar 25 1999 - 07:36:02 PST