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

Re: [leafnode-list] More embedded NULLs in posts



Matthias Andree wrote:

> I know this sucks, but \0s don't belong in news in the first
> place.

Agreed, but they appear to be there in some cases (fortunately, I have
not encountered this problem so far). It may be a problem of broken
upstream server software. In any case, people should have as little
problems as possible with that.

> I understand that after your patch, you're silently discarding the
> entire line between the NUL byte and the LF and return success.

That's something I didn't like either. I have now come up with something
that seems to replace NUL bytes with spaces. This is not optimal either,
but I think it's better than discarding parts of lines.

(I say "it seems" because I have not tested it rigorously yet.)

Patch against miscutil.c of 1.9.16 follows:

--- miscutil.c.orig	Thu Aug 24 17:32:27 2000
+++ miscutil.c	Thu Aug 24 17:35:07 2000
@@ -695,8 +695,14 @@
 	buf = critmalloc( size, "reading line" );
 
     while ((p=fgets(buf+len, size-len, f))) {
- 	if (*(buf+len) == '\0')
-	    break;		/* don't throw up on NUL bytes */
+	/* replace NUL bytes (which shouldn't be there anyway)
+	 * with spaces
+	 */
+	i = size - len;
+	while ( *p++ != '\n' && i-- > 0 ) {
+	    if ( *p == '\0' )
+		*p = ' ';
+	}
 	len += strlen(buf+len);
 	if ( buf[len-1] == '\n' )
 	    break;		/* the whole line has been read */

I would appreciate if someone could test this and tell me whether
it works satisfactorily for him or her. One could also add a syslog()
command which notifies the user about the problem.

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