usr.bin/make Correct array size (MAXPATHLEN includes trailing nu

看板DFBSD_submit作者時間21年前 (2004/11/17 21:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
This is a multi-part message in MIME format. --------------030609000500070609080906 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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 --------------030609000500070609080906 Content-Type: text/plain; name="patch-4.9" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch-4.9" --------------------- 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; --------------030609000500070609080906--
文章代碼(AID): #11cqkV00 (DFBSD_submit)