mirror of
https://github.com/openbsd/src.git
synced 2025-01-03 06:45:37 -08:00
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@
This commit is contained in:
parent
23cb575968
commit
935ba84b39
@ -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
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user