]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-cmd-nname-20080113
authorJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 13 Jan 2008 15:33:53 +0000 (15:33 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 13 Jan 2008 15:33:53 +0000 (15:33 +0000)
LICENSE MIT

Nname() is used to concatenate two strings and is frequently used with
the first string being the name of the executable perhaps with a full
path.  The static buffer specified is too small for a full path and
there was no protection against writing beyond the end of it.

(cherry picked from commit d5811091995b78d65e891b134aa0ad6955bbc30c)

src/cmd/cmd.c

index a56daaef5f9eef656ce7856b04554727c35a649f..fab9e13667e1ee7141abed36856acafa48b6534a 100644 (file)
@@ -40,13 +40,14 @@ static char initcmd_opcode[] = "initcmd";   /*Name of initcmd opcode */
 static char *
 NName(char *a1, char *a2)
 {
-    static char tbuffer[80];
+    static char tbuffer[300];
     if (strlen(a1) == 0) {
-       return "";
+        return "";
     } else {
-       strcpy(tbuffer, a1);
-       strcat(tbuffer, a2);
-       return tbuffer;
+        strncpy(tbuffer, a1, sizeof(tbuffer));
+        strncat(tbuffer, a2, sizeof(tbuffer));
+        tbuffer[sizeof(tbuffer)-1]='\0';
+        return tbuffer;
     }
 }