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

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



I wrote:

> Patch against miscutil.c of 1.9.16 follows:

Unfortunately, this patch lacked the declaration of i and therefore will
not compile. Here is the corrected version:

--- miscutil.c.orig	Thu Aug 24 17:32:27 2000
+++ miscutil.c	Thu Aug 24 17:40:27 2000
@@ -687,6 +687,7 @@
     static size_t size;     /* size of buffer */
     size_t len;             /* # of chars stored into buf before '\0' */
     char * p;
+    int i;
 
     len = 0;
     if (!size)
@@ -695,8 +696,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 */

Sorry for the inconvenience,
--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