DragonFly BSD
DragonFly submit List (threaded) for 2004-11
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

usr.bin/make Correct array size (MAXPATHLEN includes trailing nul char)


From: Max Okumoto <okumoto@home>
Date: Wed, 17 Nov 2004 04:48:08 -0800

Taken from FreeBSD 2001/03/01 06:03:17

MAXPATHLEN includes the trailing NUL.

Correct array sizes to reflect this.
Correct NUL termination after strncpy.


Max Okumoto
---------------------
PatchSet 186
Date: 2001/03/01 06:03:17
Author: imp
Log:
MAXPATHLEN includes the trailing NUL.

Correct array sizes to reflect this.
Correct NUL termination after strncpy.

# Didn't to strncpy -> strlcpy change.

Members: 
	arch.c:1.20->1.21 
	main.c:1.46->1.47 

Index: arch.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/arch.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- arch.c	16 Dec 2000 02:14:37 -0000	1.20
+++ arch.c	1 Mar 2001 06:03:17 -0000	1.21
@@ -478,7 +478,7 @@
     Arch	  *ar;	      /* Archive descriptor */
     Hash_Entry	  *he;	      /* Entry containing member's description */
     struct ar_hdr arh;        /* archive-member header for reading archive */
-    char	  memName[MAXPATHLEN+1];
+    char	  memName[MAXPATHLEN];
     	    	    	    /* Current member name while hashing. */
 
     /*
@@ -760,7 +760,7 @@
     }
 
     (void) strncpy(name, &ar->fnametab[entry], MAXPATHLEN);
-    name[MAXPATHLEN] = '\0';
+    name[MAXPATHLEN - 1] = '\0';
     return 1;
 }
 #endif
Index: main.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/main.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- main.c	19 Feb 2001 03:59:04 -0000	1.46
+++ main.c	1 Mar 2001 06:03:17 -0000	1.47
@@ -467,9 +467,9 @@
 	struct stat sb;
 	char *pwd;
 #endif
-	char mdpath[MAXPATHLEN + 1];
-	char obpath[MAXPATHLEN + 1];
-	char cdpath[MAXPATHLEN + 1];
+	char mdpath[MAXPATHLEN];
+	char obpath[MAXPATHLEN];
+	char cdpath[MAXPATHLEN];
     	char *machine = getenv("MACHINE");
 	char *machine_arch = getenv("MACHINE_ARCH");
 	char *machine_cpu = getenv("MACHINE_CPU");
@@ -936,7 +936,7 @@
 {
 	char *fname;		/* makefile to read */
 	FILE *stream;
-	char *name, path[MAXPATHLEN + 1];
+	char *name, path[MAXPATHLEN];
 	char *MAKEFILE;
 	int setMAKEFILE;
 


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