diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2017-09-12 08:32:45 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2017-09-12 08:32:45 +0000 |
commit | a03731a3adb73bebc5c713b78dfda71e38dd18da (patch) | |
tree | d74874885087a9078c0c9f5a29659011cb8c15c6 /usr.bin | |
parent | 8cd32ba648b39bc4bb5651dae2b4de7158ec7ee5 (diff) |
Include room for NUL-termination when calculating the length of archive
member name.
Fix an of by one found by sthen@ with MALLOC_OPTIONS=C.
From Matthew Martin, ok deraadt@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/nm/nm.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/nm/nm.c b/usr.bin/nm/nm.c index 5d2a1bfeb61..f9ad9399b86 100644 --- a/usr.bin/nm/nm.c +++ b/usr.bin/nm/nm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nm.c,v 1.51 2015/12/09 19:28:34 mmcc Exp $ */ +/* $OpenBSD: nm.c,v 1.52 2017/09/12 08:32:44 mpi Exp $ */ /* $NetBSD: nm.c,v 1.7 1996/01/14 23:04:03 pk Exp $ */ /* @@ -310,7 +310,7 @@ mmbr_name(struct ar_hdr *arh, char **name, int baselen, int *namelen, FILE *fp) int len; i = atol(&arh->ar_name[1]); - len = strlen(&nametab[i]); + len = strlen(&nametab[i]) + 1; if (len > *namelen) { p -= (long)*name; if ((*name = realloc(*name, baselen+len)) == NULL) @@ -319,7 +319,7 @@ mmbr_name(struct ar_hdr *arh, char **name, int baselen, int *namelen, FILE *fp) p += (long)*name; } strlcpy(p, &nametab[i], len); - p += len; + p += len - 1; } else #ifdef AR_EFMT1 /* |