
From grdetil@scrc.umanitoba.ca Fri Nov 12 12:00:25 1999
Date: Fri, 12 Nov 1999 13:42:12 -0600 (CST)
From: Gilles Detillieux <grdetil@scrc.umanitoba.ca>
To: htdig@htdig.org
Subject: [htdig] PATCH: fix bug in htsearch POST method


This fixes a bug when dealing with very long parameters provided to htsearch
via the POST method.  When the query to be read is very long (> 8K), the
read wouldn't get it all in one shot, leading to some very odd behaviour
down the line.  This seems to fix PR#668.

--- htdig-3.1.3/htlib/cgi.cc.orig	Wed Sep  1 15:25:02 1999
+++ htdig-3.1.3/htlib/cgi.cc	Fri Nov 12 13:14:32 1999
@@ -74,8 +74,10 @@ cgi::cgi()
 		if (!buf || !*buf || (n = atoi(buf)) <= 0)
 			return;		// null query
 		buf = new char[n + 1];
-		read(0, buf, n);
-		buf[n] = '\0';
+		int	r, i = 0;
+		while (i < n && (r = read(0, buf+i, n-i)) > 0)
+			i += r;
+		buf[i] = '\0';
 		results = buf;
 		delete buf;
 	}


-- 
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.
