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

Re: [leafnode-list] Errors running Fetchnews



Goldarg wrote:

> I just got the system I have been useing for a news server running again
> after a hardware failure and when running fetchnews I'm getting errors
> that I cant seem to get past, The error is:
> realloc(23330716) failed: reading line

This error seems to occur quite often recently. It appears that some
articles contain NUL bytes which cause the getaline() function to
go into an endless loop.

The following patch, written by Matthias Andree, may cure the problem.
I have not tested it myself because I have not encountered the problem
so far. If it works for you (or anybody else) I would appreciate some
feedback.

--- miscutil.c.orig	Mon Jul 24 22:28:04 2000
+++ miscutil.c	Mon Jul 24 22:28:47 2000
@@ -694,12 +694,14 @@
     if (!buf)
 	buf = critmalloc( size, "reading line" );
 
-    while ((p=fgets(buf+len, size-len, f)) != NULL) {
+    while ((p=fgets(buf+len, size-len, f))) {
+ 	if (*(buf+len) == '\0')
+	    break;		/* don't throw up on NUL bytes */
 	len += strlen(buf+len);
-        if (len > 0 && ( buf[len-1] == '\n' || len < size-1 ) )
-	    break;          /* the whole line has been read */
+	if ( buf[len-1] == '\n' )
+	    break;		/* the whole line has been read */
 
-	size += size+100;
+	size += size;		/* exponential growth of buffer */
 	buf = critrealloc(buf, size, "reading line" );
     }
 
--Cornelius.

-- 
/* Cornelius Krasel, U Wuerzburg, Dept. of Pharmacology, Versbacher Str. 9 */
/* D-97078 Wuerzburg, Germany   email: phak004@xxxxxxxxxxxxxxxxxxxxxx  SP4 */
/* "Science is the game we play with God to find out what His rules are."  */

-- 
leafnode-list@xxxxxxxxxxxxxxxxxxxxxxxxxxxx -- mailing list for leafnode
To unsubscribe, send mail with "unsubscribe" in the subject to the list