🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
3 messages
3 total messages Started by Francis C. Swasey Fri, 25 Jul 1997 00:00
strlen of strncpy (1.6b2)
#19671
Author: Francis C. Swasey
Date: Fri, 25 Jul 1997 00:00
255 lines
10212 bytes
It was pointed out by Forrest J. Cavalier III yesterday afternoon that
code such as

p += strlen(strncpy(p, "running", sizeof(buff) - strlen(buff) - 1));

is dangerous.  Since strncpy is not guaranteed to null terminate the string it returns, you cannot be sure that (in the above case) you are doing the equivalent of:

(void)strncpy(p, "running", sizeof(buff) - strlen(buff) - 1);
p += strlne("running");

So, here's a patch for the four .c files that have this problem:

-------------------8<--------------------8<-------------------8<-----------
--- innd/art.c.orig	Wed Jul 23 13:09:28 1997
+++ innd/art.c	Fri Jul 25 18:28:44 1997
@@ -2652,7 +2652,8 @@
 		ARTreject(buff, article);
 		return buff;
 	    }
-	    p += strlen(strncpy(p, Data.Name, Files.Size - 1));
+	    (void)strncpy(p, Data.Name, Files.Size - 1);
+	    p += strlen(Data.Name);
 	    Files.Data[Files.Size - 1] = '\0';
 	    Data.NameLength = strlen(Data.Name);
 	}
--- innd/cc.c.orig	Wed Jul 23 13:09:28 1997
+++ innd/cc.c	Fri Jul 25 18:29:51 1997
@@ -801,32 +801,40 @@
 	p += strlen(p);
 	break;
     case OMrunning:
-	p += strlen(strncpy(p, "running", sizeof(buff) - strlen(buff) - 1));
+	(void)strncpy(p, "running", sizeof(buff) - strlen(buff) - 1);
+	p += strlen("running");
 	buff[sizeof(buff) - 1] = '\0';
 	break;
     case OMpaused:
-	p += strlen(strncpy(p, "paused ", sizeof(buff) - strlen(buff) - 1));
+	(void)strncpy(p, "paused ", sizeof(buff) - strlen(buff) - 1);
+	p += strlen("paused ");
 	buff[sizeof(buff) - 1] = '\0';
-	p += strlen(strncpy(p, ModeReason, sizeof(buff) - strlen(buff) - 1));
+	(void)strncpy(p, ModeReason, sizeof(buff) - strlen(buff) - 1);
+	p += strlen(ModeReason);
 	buff[sizeof(buff) - 1] = '\0';
 	break;
     case OMthrottled:
-	p += strlen(strncpy(p, "throttled ", sizeof(buff) - strlen(buff) - 1));
+	(void)strncpy(p, "throttled ", sizeof(buff) - strlen(buff) - 1);
+	p += strlen("throttled ");
 	buff[sizeof(buff) - 1] = '\0';
-	p += strlen(strncpy(p, ModeReason, sizeof(buff) - strlen(buff) - 1));
+	(void)strncpy(p, ModeReason, sizeof(buff) - strlen(buff) - 1);
+	p += strlen(ModeReason);
 	buff[sizeof(buff) - 1] = '\0';
 	break;
     }
     *p++ = '\n';
     if (RejectReason) {
-	p += strlen(strncpy(p, "Rejecting ", sizeof(buff) - strlen(buff) - 1));
+	(void)strncpy(p, "Rejecting ", sizeof(buff) - strlen(buff) - 1);
+	p += strlen("Rejecting ");
 	buff[sizeof(buff) - 1] = '\0';
-	p += strlen(strncpy(p, RejectReason, sizeof(buff) - strlen(buff) - 1));
+	(void)strncpy(p, RejectReason, sizeof(buff) - strlen(buff) - 1);
+	p += strlen(RejectReason);
 	buff[sizeof(buff) - 1] = '\0';
     }
     else {
-	p += strlen(strncpy(p, "Allowing remote connections",
-				sizeof(buff) - strlen(buff) - 1));
+	(void)strncpy(p, "Allowing remote connections",
+				sizeof(buff) - strlen(buff) - 1);
+	p += strlen("Allowing remote connections");
 	buff[sizeof(buff) - 1] = '\0';
     }
 
@@ -852,23 +860,28 @@
 	p += strlen(p);
     }
     else {
-	p += strlen(strncpy(p, "Not reserved", sizeof(buff)-strlen(buff)-1));
+	(void)strncpy(p, "Not reserved", sizeof(buff)-strlen(buff)-1);
+	p += strlen("Not reserved");
 	buff[sizeof(buff) - 1] = '\0';
     }
 
     /* Newsreaders. */
     *p++ = '\n';
-    p += strlen(strncpy(p, "Readers ", sizeof(buff) - strlen(buff) - 1));
+    (void)strncpy(p, "Readers ", sizeof(buff) - strlen(buff) - 1);
+    p += strlen("Readers ");
     buff[sizeof(buff) - 1] = '\0';
     if (NNRPFollows) {
-	p += strlen(strncpy(p, "follow ", sizeof(buff) - strlen(buff) - 1));
+	(void)strncpy(p, "follow ", sizeof(buff) - strlen(buff) - 1);
+	p += strlen("follow ");
 	buff[sizeof(buff) - 1] = '\0';
     } else {
-	p += strlen(strncpy(p, "separate ", sizeof(buff) - strlen(buff) - 1));
+	(void)strncpy(p, "separate ", sizeof(buff) - strlen(buff) - 1);
+	p += strlen("separate ");
 	buff[sizeof(buff) - 1] = '\0';
     }
     if (NNRPReason == NULL) {
-	p += strlen(strncpy(p, "enabled", sizeof(buff) - strlen(buff) - 1));
+	(void)strncpy(p, "enabled", sizeof(buff) - strlen(buff) - 1);
+	p += strlen("enabled");
 	buff[sizeof(buff) - 1] = '\0';
     } else {
 	(void)snprintf(p, sizeof(buff) - strlen(buff),
@@ -878,25 +891,31 @@
 
 #if defined(DO_TCL)
     *p++ = '\n';
-    p += strlen(strncpy(p, "Tcl filtering ", sizeof(buff) - strlen(buff) - 1));
+    (void)strncpy(p, "Tcl filtering ", sizeof(buff) - strlen(buff) - 1);
+    p += strlen("Tcl filtering ");
     buff[sizeof(buff) - 1] = '\0';
     if (TCLFilterActive) {
-	p += strlen(strncpy(p, "enabled", sizeof(buff) - strlen(buff) - 1));
+	(void)strncpy(p, "enabled", sizeof(buff) - strlen(buff) - 1);
+	p += strlen("enabled");
 	buff[sizeof(buff) - 1] = '\0';
     } else {
-	p += strlen(strncpy(p, "disabled", sizeof(buff) - strlen(buff) - 1));
+	(void)strncpy(p, "disabled", sizeof(buff) - strlen(buff) - 1);
+	p += strlen("disabled");
 	buff[sizeof(buff) - 1] = '\0';
     }
 #endif /* defined(DO_TCL) */
 #if defined(DO_PERL)
     *p++ = '\n';
-    p += strlen(strncpy(p, "Perl filtering ", sizeof(buff) - strlen(buff) - 1));
+    (void)strncpy(p, "Perl filtering ", sizeof(buff) - strlen(buff) - 1);
+    p += strlen("Perl filtering ");
     buff[sizeof(buff) - 1] = '\0';
     if (PerlFilterActive) {
-        p += strlen(strncpy(p, "enabled", sizeof(buff) - strlen(buff) - 1));
+        (void)strncpy(p, "enabled", sizeof(buff) - strlen(buff) - 1);
+        p += strlen("enabled");
 	buff[sizeof(buff) - 1] = '\0';
     } else {
-        p += strlen(strncpy(p, "disabled", sizeof(buff) - strlen(buff) - 1));
+        (void)strncpy(p, "disabled", sizeof(buff) - strlen(buff) - 1);
+        p += strlen("disabled");
 	buff[sizeof(buff) - 1] = '\0';
     }
 #endif /* defined(DO_PERL) */
--- innd/site.c.orig	Wed Jul 23 13:09:28 1997
+++ innd/site.c	Fri Jul 25 18:24:55 1997
@@ -1173,7 +1173,8 @@
 	break;
     case FTerror:
     case FTfile:
-	p += strlen(strncpy(p, "file", sizeof(buff) - strlen(buff) - 1));
+	(void)strncpy(p, "file", sizeof(buff) - strlen(buff) - 1);
+	p += strlen("file");
 	buff[sizeof(buff) - 1] = '\0';
 	if (sp->Buffered) {
 	    (void)snprintf(p, sizeof(buff) - strlen(buff),
@@ -1181,8 +1182,8 @@
 	    p += strlen(p);
 	}
 	else if ((cp = sp->Channel) == NULL) {
-	    p += strlen(strncpy(p, " no channel?",
-			sizeof(buff) - strlen(buff) - 1));
+	    (void)strncpy(p, " no channel?", sizeof(buff) - strlen(buff) - 1);
+	    p += strlen(" no channel?");
 	    buff[sizeof(buff) - 1] = '\0';
 	} else {
 	    (void)snprintf(p, sizeof(buff) - strlen(buff),
@@ -1191,11 +1192,13 @@
 	}
 	break;
     case FTchannel:
-	p += strlen(strncpy(p, "channel", sizeof(buff) - strlen(buff) - 1));
+	(void)strncpy(p, "channel", sizeof(buff) - strlen(buff) - 1);
+	p += strlen("channel");
 	buff[sizeof(buff) - 1] = '\0';
 	goto Common;
     case FTexploder:
-	p += strlen(strncpy(p, "exploder", sizeof(buff) - strlen(buff) - 1));
+	(void)strncpy(p, "exploder", sizeof(buff) - strlen(buff) - 1);
+	p += strlen("exploder");
 	buff[sizeof(buff) - 1] = '\0';
 Common:
 	if (sp->Process >= 0) {
@@ -1204,12 +1207,13 @@
 	    p += strlen(p);
 	}
 	if (sp->Spooling) {
-	    p += strlen(strncpy(p, " spooling", sizeof(buff)-strlen(buff)-1));
+	    (void)strncpy(p, " spooling", sizeof(buff)-strlen(buff)-1);
+	    p += strlen(" spooling");
 	    buff[sizeof(buff) - 1] = '\0';
 	}
 	if ((cp = sp->Channel) == NULL) {
-	    p += strlen(strncpy(p, " no channel?",
-			sizeof(buff) - strlen(buff) - 1));
+	    (void)strncpy(p, " no channel?", sizeof(buff) - strlen(buff) - 1);
+	    p += strlen(" no channel?");
 	    buff[sizeof(buff) - 1] = '\0';
 	} else {
 	    (void)snprintf(p, sizeof(buff) - strlen(buff),
@@ -1218,19 +1222,22 @@
 	}
 	break;
     case FTfunnel:
-	p += strlen(strncpy(p,"recursive funnel",sizeof(buff)-strlen(buff)-1));
+	(void)strncpy(p,"recursive funnel",sizeof(buff)-strlen(buff)-1);
+	p += strlen("recursive funnel");
 	buff[sizeof(buff) - 1] = '\0';
 	break;
     case FTlogonly:
-	p += strlen(strncpy(p, "log only", sizeof(buff) - strlen(buff) - 1));
+	(void)strncpy(p, "log only", sizeof(buff) - strlen(buff) - 1);
+	p += strlen("log only");
 	buff[sizeof(buff) - 1] = '\0';
 	break;
     case FTprogram:
-	p += strlen(strncpy(p, "program", sizeof(buff) - strlen(buff) - 1));
+	(void)strncpy(p, "program", sizeof(buff) - strlen(buff) - 1);
+	p += strlen("program");
 	buff[sizeof(buff) - 1] = '\0';
 	if (sp->FNLwantsnames) {
-	    p += strlen(strncpy(p, " with names",
-				sizeof(buff) - strlen(buff) - 1));
+	    (void)strncpy(p, " with names", sizeof(buff) - strlen(buff) - 1);
+	    p += strlen(" with names");
 	    buff[sizeof(buff) - 1] = '\0';
 	}
 	break;
--- lib/inndcomm.c.orig	Wed Jul 23 13:09:28 1997
+++ lib/inndcomm.c	Fri Jul 25 18:25:23 1997
@@ -234,7 +234,8 @@
     for (p = buff + strlen(buff), i = 0; (q = argv[i]) != NULL; i++) {
 	*p++ = SC_SEP;
         *p = '\0'; /* make sure buff is null-terminated so strlen below will work! */
-        p += strlen(strncpy(p, q, bufsiz - strlen(buff) - 1 - HEADER_SIZE));
+        (void)strncpy(p, q, bufsiz - strlen(buff) - 1 - HEADER_SIZE);
+        p += strlen(q);
         buff[bufsiz - 1 - HEADER_SIZE] = '\0'; 
     }
 
-------------------8<--------------------8<-------------------8<-----------

Frank
-- 
e-mail: fswasey@btv.ibm.com                                   ,,,
Tel: 802-769-4011 (tie: 446), Fax: 802-769-4253 (tie: 446)   (o o)
           Speaking *from* but not *for* IBM           -oOOO--(_)--OOOo-

Re: strlen of strncpy (1.6b2)
#19739
Author: Forrest J. Cavalier III
Date: Mon, 28 Jul 1997 00:00
49 lines
2068 bytes
Posted and e-mailed.

In article <5rba4b$6e2@fangorn.btv.ibm.com>, fswasey@fangorn.btv.ibm.com 
wrote...
>
>It was pointed out by Forrest J. Cavalier III yesterday afternoon that
>code such as
>
>p += strlen(strncpy(p, "running", sizeof(buff) - strlen(buff) - 1));
>
>is dangerous.  Since strncpy is not guaranteed to null terminate the string it 
returns, you cannot be sure that (in the above case) you are doing the equi
>
>(void)strncpy(p, "running", sizeof(buff) - strlen(buff) - 1);
>p += strlne("running");
>
>So, here's a patch for the four .c files that have this problem:

>
>-------------------8<--------------------8<-------------------8<-----------
>--- innd/art.c.orig     Wed Jul 23 13:09:28 1997
>+++ innd/art.c  Fri Jul 25 18:28:44 1997
>@@ -2652,7 +2652,8 @@
>                ARTreject(buff, article);
>                return buff;
>            }
>-           p += strlen(strncpy(p, Data.Name, Files.Size - 1));
>+           (void)strncpy(p, Data.Name, Files.Size - 1);
>+           p += strlen(Data.Name);
>            Files.Data[Files.Size - 1] = '\0';
>            Data.NameLength = strlen(Data.Name);
>        }

[rest of patch, with similar fixes, snipped]

   Your patch is equally dangerous.  You advance p by the size
   of Data.Name, when it is possible that fewer characters were
   copied. Your patch fails with the same cases that the strlen(strncpy())
   fails.

   A simple solution is to place the storage of '\0' BEFORE the
   strncpy().


Forrest


Re: strlen of strncpy (1.6b2)
#19744
Author: Francis C. Swasey
Date: Mon, 28 Jul 1997 00:00
469 lines
18501 bytes
Forrest is quite right.  My patch is no better than the original 1.6b2
version, because I don't keep p pointing inside buff and there are
places where "*p" is blindly assigned a newline.  Thus, here's a new
patch against the original files.  The second patch following is if
you applied my first patch, to convert to the new patch.

Patch 1: Apply if you did not put on my first patch
------------------8<------------------8<-----------------8<-----------
--- innd/art.c.orig	Wed Jul 23 13:09:28 1997
+++ innd/art.c	Mon Jul 28 10:16:55 1997
@@ -2652,8 +2652,8 @@
 		ARTreject(buff, article);
 		return buff;
 	    }
-	    p += strlen(strncpy(p, Data.Name, Files.Size - 1));
 	    Files.Data[Files.Size - 1] = '\0';
+	    p += strlen(strncpy(p, Data.Name, Files.Size - 1));
 	    Data.NameLength = strlen(Data.Name);
 	}
 	else {
--- innd/cc.c.orig	Wed Jul 23 13:09:28 1997
+++ innd/cc.c	Mon Jul 28 10:19:31 1997
@@ -801,33 +801,33 @@
 	p += strlen(p);
 	break;
     case OMrunning:
-	p += strlen(strncpy(p, "running", sizeof(buff) - strlen(buff) - 1));
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "running", sizeof(buff) - strlen(buff) - 1));
 	break;
     case OMpaused:
+	buff[sizeof(buff) - 1] = '\0';
 	p += strlen(strncpy(p, "paused ", sizeof(buff) - strlen(buff) - 1));
 	buff[sizeof(buff) - 1] = '\0';
 	p += strlen(strncpy(p, ModeReason, sizeof(buff) - strlen(buff) - 1));
-	buff[sizeof(buff) - 1] = '\0';
 	break;
     case OMthrottled:
+	buff[sizeof(buff) - 1] = '\0';
 	p += strlen(strncpy(p, "throttled ", sizeof(buff) - strlen(buff) - 1));
 	buff[sizeof(buff) - 1] = '\0';
 	p += strlen(strncpy(p, ModeReason, sizeof(buff) - strlen(buff) - 1));
-	buff[sizeof(buff) - 1] = '\0';
 	break;
     }
     *p++ = '\n';
     if (RejectReason) {
+	buff[sizeof(buff) - 1] = '\0';
 	p += strlen(strncpy(p, "Rejecting ", sizeof(buff) - strlen(buff) - 1));
 	buff[sizeof(buff) - 1] = '\0';
 	p += strlen(strncpy(p, RejectReason, sizeof(buff) - strlen(buff) - 1));
-	buff[sizeof(buff) - 1] = '\0';
     }
     else {
+	buff[sizeof(buff) - 1] = '\0';
 	p += strlen(strncpy(p, "Allowing remote connections",
 				sizeof(buff) - strlen(buff) - 1));
-	buff[sizeof(buff) - 1] = '\0';
     }
 
     /* Server parameters. */
@@ -852,24 +852,24 @@
 	p += strlen(p);
     }
     else {
-	p += strlen(strncpy(p, "Not reserved", sizeof(buff)-strlen(buff)-1));
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "Not reserved", sizeof(buff)-strlen(buff)-1));
     }
 
     /* Newsreaders. */
     *p++ = '\n';
-    p += strlen(strncpy(p, "Readers ", sizeof(buff) - strlen(buff) - 1));
     buff[sizeof(buff) - 1] = '\0';
+    p += strlen(strncpy(p, "Readers ", sizeof(buff) - strlen(buff) - 1));
     if (NNRPFollows) {
-	p += strlen(strncpy(p, "follow ", sizeof(buff) - strlen(buff) - 1));
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "follow ", sizeof(buff) - strlen(buff) - 1));
     } else {
-	p += strlen(strncpy(p, "separate ", sizeof(buff) - strlen(buff) - 1));
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "separate ", sizeof(buff) - strlen(buff) - 1));
     }
     if (NNRPReason == NULL) {
-	p += strlen(strncpy(p, "enabled", sizeof(buff) - strlen(buff) - 1));
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "enabled", sizeof(buff) - strlen(buff) - 1));
     } else {
 	(void)snprintf(p, sizeof(buff) - strlen(buff),
 		"disabled %s", NNRPReason);
@@ -878,26 +878,26 @@
 
 #if defined(DO_TCL)
     *p++ = '\n';
-    p += strlen(strncpy(p, "Tcl filtering ", sizeof(buff) - strlen(buff) - 1));
     buff[sizeof(buff) - 1] = '\0';
+    p += strlen(strncpy(p, "Tcl filtering ", sizeof(buff) - strlen(buff) - 1));
     if (TCLFilterActive) {
-	p += strlen(strncpy(p, "enabled", sizeof(buff) - strlen(buff) - 1));
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "enabled", sizeof(buff) - strlen(buff) - 1));
     } else {
-	p += strlen(strncpy(p, "disabled", sizeof(buff) - strlen(buff) - 1));
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "disabled", sizeof(buff) - strlen(buff) - 1));
     }
 #endif /* defined(DO_TCL) */
 #if defined(DO_PERL)
     *p++ = '\n';
-    p += strlen(strncpy(p, "Perl filtering ", sizeof(buff) - strlen(buff) - 1));
     buff[sizeof(buff) - 1] = '\0';
+    p += strlen(strncpy(p, "Perl filtering ", sizeof(buff) - strlen(buff) - 1));
     if (PerlFilterActive) {
-        p += strlen(strncpy(p, "enabled", sizeof(buff) - strlen(buff) - 1));
 	buff[sizeof(buff) - 1] = '\0';
+        p += strlen(strncpy(p, "enabled", sizeof(buff) - strlen(buff) - 1));
     } else {
-        p += strlen(strncpy(p, "disabled", sizeof(buff) - strlen(buff) - 1));
 	buff[sizeof(buff) - 1] = '\0';
+        p += strlen(strncpy(p, "disabled", sizeof(buff) - strlen(buff) - 1));
     }
 #endif /* defined(DO_PERL) */
 
--- innd/site.c.orig	Wed Jul 23 13:09:28 1997
+++ innd/site.c	Mon Jul 28 10:20:42 1997
@@ -1173,17 +1173,17 @@
 	break;
     case FTerror:
     case FTfile:
-	p += strlen(strncpy(p, "file", sizeof(buff) - strlen(buff) - 1));
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "file", sizeof(buff) - strlen(buff) - 1));
 	if (sp->Buffered) {
 	    (void)snprintf(p, sizeof(buff) - strlen(buff),
 		" buffered(%ld)", sp->Buffer.Left);
 	    p += strlen(p);
 	}
 	else if ((cp = sp->Channel) == NULL) {
+	    buff[sizeof(buff) - 1] = '\0';
 	    p += strlen(strncpy(p, " no channel?",
 			sizeof(buff) - strlen(buff) - 1));
-	    buff[sizeof(buff) - 1] = '\0';
 	} else {
 	    (void)snprintf(p, sizeof(buff) - strlen(buff),
 		" open fd=%d, in mem %ld", cp->fd, cp->Out.Left);
@@ -1191,12 +1191,12 @@
 	}
 	break;
     case FTchannel:
-	p += strlen(strncpy(p, "channel", sizeof(buff) - strlen(buff) - 1));
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "channel", sizeof(buff) - strlen(buff) - 1));
 	goto Common;
     case FTexploder:
-	p += strlen(strncpy(p, "exploder", sizeof(buff) - strlen(buff) - 1));
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "exploder", sizeof(buff) - strlen(buff) - 1));
 Common:
 	if (sp->Process >= 0) {
 	    (void)snprintf(p, sizeof(buff) - strlen(buff),
@@ -1204,13 +1204,13 @@
 	    p += strlen(p);
 	}
 	if (sp->Spooling) {
-	    p += strlen(strncpy(p, " spooling", sizeof(buff)-strlen(buff)-1));
 	    buff[sizeof(buff) - 1] = '\0';
+	    p += strlen(strncpy(p, " spooling", sizeof(buff)-strlen(buff)-1));
 	}
 	if ((cp = sp->Channel) == NULL) {
+	    buff[sizeof(buff) - 1] = '\0';
 	    p += strlen(strncpy(p, " no channel?",
 			sizeof(buff) - strlen(buff) - 1));
-	    buff[sizeof(buff) - 1] = '\0';
 	} else {
 	    (void)snprintf(p, sizeof(buff) - strlen(buff),
 		" fd=%d, in mem %ld", cp->fd, cp->Out.Left);
@@ -1218,20 +1218,20 @@
 	}
 	break;
     case FTfunnel:
-	p += strlen(strncpy(p,"recursive funnel",sizeof(buff)-strlen(buff)-1));
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p,"recursive funnel",sizeof(buff)-strlen(buff)-1));
 	break;
     case FTlogonly:
-	p += strlen(strncpy(p, "log only", sizeof(buff) - strlen(buff) - 1));
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "log only", sizeof(buff) - strlen(buff) - 1));
 	break;
     case FTprogram:
-	p += strlen(strncpy(p, "program", sizeof(buff) - strlen(buff) - 1));
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "program", sizeof(buff) - strlen(buff) - 1));
 	if (sp->FNLwantsnames) {
+	    buff[sizeof(buff) - 1] = '\0';
 	    p += strlen(strncpy(p, " with names",
 				sizeof(buff) - strlen(buff) - 1));
-	    buff[sizeof(buff) - 1] = '\0';
 	}
 	break;
     }
--- lib/inndcomm.c.orig	Wed Jul 23 13:09:28 1997
+++ lib/inndcomm.c	Mon Jul 28 10:22:21 1997
@@ -234,8 +234,8 @@
     for (p = buff + strlen(buff), i = 0; (q = argv[i]) != NULL; i++) {
 	*p++ = SC_SEP;
         *p = '\0'; /* make sure buff is null-terminated so strlen below will work! */
-        p += strlen(strncpy(p, q, bufsiz - strlen(buff) - 1 - HEADER_SIZE));
         buff[bufsiz - 1 - HEADER_SIZE] = '\0'; 
+        p += strlen(strncpy(p, q, bufsiz - strlen(buff) - 1 - HEADER_SIZE));
     }
 
     /* Send message. */
------------------8<------------------8<-----------------8<-----------

Patch 2: Apply if you did put on my first patch from July 25th
------------------8<------------------8<-----------------8<-----------
--- innd/art.c.orig2	Fri Jul 25 18:28:44 1997
+++ innd/art.c	Mon Jul 28 10:16:55 1997
@@ -2652,9 +2652,8 @@
 		ARTreject(buff, article);
 		return buff;
 	    }
-	    (void)strncpy(p, Data.Name, Files.Size - 1);
-	    p += strlen(Data.Name);
 	    Files.Data[Files.Size - 1] = '\0';
+	    p += strlen(strncpy(p, Data.Name, Files.Size - 1));
 	    Data.NameLength = strlen(Data.Name);
 	}
 	else {
--- innd/cc.c.orig2	Fri Jul 25 18:29:51 1997
+++ innd/cc.c	Mon Jul 28 10:19:31 1997
@@ -801,41 +801,33 @@
 	p += strlen(p);
 	break;
     case OMrunning:
-	(void)strncpy(p, "running", sizeof(buff) - strlen(buff) - 1);
-	p += strlen("running");
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "running", sizeof(buff) - strlen(buff) - 1));
 	break;
     case OMpaused:
-	(void)strncpy(p, "paused ", sizeof(buff) - strlen(buff) - 1);
-	p += strlen("paused ");
 	buff[sizeof(buff) - 1] = '\0';
-	(void)strncpy(p, ModeReason, sizeof(buff) - strlen(buff) - 1);
-	p += strlen(ModeReason);
+	p += strlen(strncpy(p, "paused ", sizeof(buff) - strlen(buff) - 1));
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, ModeReason, sizeof(buff) - strlen(buff) - 1));
 	break;
     case OMthrottled:
-	(void)strncpy(p, "throttled ", sizeof(buff) - strlen(buff) - 1);
-	p += strlen("throttled ");
 	buff[sizeof(buff) - 1] = '\0';
-	(void)strncpy(p, ModeReason, sizeof(buff) - strlen(buff) - 1);
-	p += strlen(ModeReason);
+	p += strlen(strncpy(p, "throttled ", sizeof(buff) - strlen(buff) - 1));
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, ModeReason, sizeof(buff) - strlen(buff) - 1));
 	break;
     }
     *p++ = '\n';
     if (RejectReason) {
-	(void)strncpy(p, "Rejecting ", sizeof(buff) - strlen(buff) - 1);
-	p += strlen("Rejecting ");
 	buff[sizeof(buff) - 1] = '\0';
-	(void)strncpy(p, RejectReason, sizeof(buff) - strlen(buff) - 1);
-	p += strlen(RejectReason);
+	p += strlen(strncpy(p, "Rejecting ", sizeof(buff) - strlen(buff) - 1));
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, RejectReason, sizeof(buff) - strlen(buff) - 1));
     }
     else {
-	(void)strncpy(p, "Allowing remote connections",
-				sizeof(buff) - strlen(buff) - 1);
-	p += strlen("Allowing remote connections");
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "Allowing remote connections",
+				sizeof(buff) - strlen(buff) - 1));
     }
 
     /* Server parameters. */
@@ -860,29 +852,24 @@
 	p += strlen(p);
     }
     else {
-	(void)strncpy(p, "Not reserved", sizeof(buff)-strlen(buff)-1);
-	p += strlen("Not reserved");
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "Not reserved", sizeof(buff)-strlen(buff)-1));
     }
 
     /* Newsreaders. */
     *p++ = '\n';
-    (void)strncpy(p, "Readers ", sizeof(buff) - strlen(buff) - 1);
-    p += strlen("Readers ");
     buff[sizeof(buff) - 1] = '\0';
+    p += strlen(strncpy(p, "Readers ", sizeof(buff) - strlen(buff) - 1));
     if (NNRPFollows) {
-	(void)strncpy(p, "follow ", sizeof(buff) - strlen(buff) - 1);
-	p += strlen("follow ");
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "follow ", sizeof(buff) - strlen(buff) - 1));
     } else {
-	(void)strncpy(p, "separate ", sizeof(buff) - strlen(buff) - 1);
-	p += strlen("separate ");
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "separate ", sizeof(buff) - strlen(buff) - 1));
     }
     if (NNRPReason == NULL) {
-	(void)strncpy(p, "enabled", sizeof(buff) - strlen(buff) - 1);
-	p += strlen("enabled");
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "enabled", sizeof(buff) - strlen(buff) - 1));
     } else {
 	(void)snprintf(p, sizeof(buff) - strlen(buff),
 		"disabled %s", NNRPReason);
@@ -891,32 +878,26 @@
 
 #if defined(DO_TCL)
     *p++ = '\n';
-    (void)strncpy(p, "Tcl filtering ", sizeof(buff) - strlen(buff) - 1);
-    p += strlen("Tcl filtering ");
     buff[sizeof(buff) - 1] = '\0';
+    p += strlen(strncpy(p, "Tcl filtering ", sizeof(buff) - strlen(buff) - 1));
     if (TCLFilterActive) {
-	(void)strncpy(p, "enabled", sizeof(buff) - strlen(buff) - 1);
-	p += strlen("enabled");
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "enabled", sizeof(buff) - strlen(buff) - 1));
     } else {
-	(void)strncpy(p, "disabled", sizeof(buff) - strlen(buff) - 1);
-	p += strlen("disabled");
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "disabled", sizeof(buff) - strlen(buff) - 1));
     }
 #endif /* defined(DO_TCL) */
 #if defined(DO_PERL)
     *p++ = '\n';
-    (void)strncpy(p, "Perl filtering ", sizeof(buff) - strlen(buff) - 1);
-    p += strlen("Perl filtering ");
     buff[sizeof(buff) - 1] = '\0';
+    p += strlen(strncpy(p, "Perl filtering ", sizeof(buff) - strlen(buff) - 1));
     if (PerlFilterActive) {
-        (void)strncpy(p, "enabled", sizeof(buff) - strlen(buff) - 1);
-        p += strlen("enabled");
 	buff[sizeof(buff) - 1] = '\0';
+        p += strlen(strncpy(p, "enabled", sizeof(buff) - strlen(buff) - 1));
     } else {
-        (void)strncpy(p, "disabled", sizeof(buff) - strlen(buff) - 1);
-        p += strlen("disabled");
 	buff[sizeof(buff) - 1] = '\0';
+        p += strlen(strncpy(p, "disabled", sizeof(buff) - strlen(buff) - 1));
     }
 #endif /* defined(DO_PERL) */
 
--- innd/site.c.orig2	Fri Jul 25 18:24:55 1997
+++ innd/site.c	Mon Jul 28 10:20:42 1997
@@ -1173,18 +1173,17 @@
 	break;
     case FTerror:
     case FTfile:
-	(void)strncpy(p, "file", sizeof(buff) - strlen(buff) - 1);
-	p += strlen("file");
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "file", sizeof(buff) - strlen(buff) - 1));
 	if (sp->Buffered) {
 	    (void)snprintf(p, sizeof(buff) - strlen(buff),
 		" buffered(%ld)", sp->Buffer.Left);
 	    p += strlen(p);
 	}
 	else if ((cp = sp->Channel) == NULL) {
-	    (void)strncpy(p, " no channel?", sizeof(buff) - strlen(buff) - 1);
-	    p += strlen(" no channel?");
 	    buff[sizeof(buff) - 1] = '\0';
+	    p += strlen(strncpy(p, " no channel?",
+			sizeof(buff) - strlen(buff) - 1));
 	} else {
 	    (void)snprintf(p, sizeof(buff) - strlen(buff),
 		" open fd=%d, in mem %ld", cp->fd, cp->Out.Left);
@@ -1192,14 +1191,12 @@
 	}
 	break;
     case FTchannel:
-	(void)strncpy(p, "channel", sizeof(buff) - strlen(buff) - 1);
-	p += strlen("channel");
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "channel", sizeof(buff) - strlen(buff) - 1));
 	goto Common;
     case FTexploder:
-	(void)strncpy(p, "exploder", sizeof(buff) - strlen(buff) - 1);
-	p += strlen("exploder");
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "exploder", sizeof(buff) - strlen(buff) - 1));
 Common:
 	if (sp->Process >= 0) {
 	    (void)snprintf(p, sizeof(buff) - strlen(buff),
@@ -1207,14 +1204,13 @@
 	    p += strlen(p);
 	}
 	if (sp->Spooling) {
-	    (void)strncpy(p, " spooling", sizeof(buff)-strlen(buff)-1);
-	    p += strlen(" spooling");
 	    buff[sizeof(buff) - 1] = '\0';
+	    p += strlen(strncpy(p, " spooling", sizeof(buff)-strlen(buff)-1));
 	}
 	if ((cp = sp->Channel) == NULL) {
-	    (void)strncpy(p, " no channel?", sizeof(buff) - strlen(buff) - 1);
-	    p += strlen(" no channel?");
 	    buff[sizeof(buff) - 1] = '\0';
+	    p += strlen(strncpy(p, " no channel?",
+			sizeof(buff) - strlen(buff) - 1));
 	} else {
 	    (void)snprintf(p, sizeof(buff) - strlen(buff),
 		" fd=%d, in mem %ld", cp->fd, cp->Out.Left);
@@ -1222,23 +1218,20 @@
 	}
 	break;
     case FTfunnel:
-	(void)strncpy(p,"recursive funnel",sizeof(buff)-strlen(buff)-1);
-	p += strlen("recursive funnel");
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p,"recursive funnel",sizeof(buff)-strlen(buff)-1));
 	break;
     case FTlogonly:
-	(void)strncpy(p, "log only", sizeof(buff) - strlen(buff) - 1);
-	p += strlen("log only");
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "log only", sizeof(buff) - strlen(buff) - 1));
 	break;
     case FTprogram:
-	(void)strncpy(p, "program", sizeof(buff) - strlen(buff) - 1);
-	p += strlen("program");
 	buff[sizeof(buff) - 1] = '\0';
+	p += strlen(strncpy(p, "program", sizeof(buff) - strlen(buff) - 1));
 	if (sp->FNLwantsnames) {
-	    (void)strncpy(p, " with names", sizeof(buff) - strlen(buff) - 1);
-	    p += strlen(" with names");
 	    buff[sizeof(buff) - 1] = '\0';
+	    p += strlen(strncpy(p, " with names",
+				sizeof(buff) - strlen(buff) - 1));
 	}
 	break;
     }
--- lib/inndcomm.c.orig2	Fri Jul 25 18:25:23 1997
+++ lib/inndcomm.c	Mon Jul 28 10:22:21 1997
@@ -234,9 +234,8 @@
     for (p = buff + strlen(buff), i = 0; (q = argv[i]) != NULL; i++) {
 	*p++ = SC_SEP;
         *p = '\0'; /* make sure buff is null-terminated so strlen below will work! */
-        (void)strncpy(p, q, bufsiz - strlen(buff) - 1 - HEADER_SIZE);
-        p += strlen(q);
         buff[bufsiz - 1 - HEADER_SIZE] = '\0'; 
+        p += strlen(strncpy(p, q, bufsiz - strlen(buff) - 1 - HEADER_SIZE));
     }
 
     /* Send message. */
------------------8<------------------8<-----------------8<-----------

Frank
-- 
e-mail: fswasey@btv.ibm.com                                   ,,,
Tel: 802-769-4011 (tie: 446), Fax: 802-769-4253 (tie: 446)   (o o)
           Speaking *from* but not *for* IBM           -oOOO--(_)--OOOo-

Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads