summaryrefslogtreecommitdiffstats
path: root/usr.bin/make
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2005-02-21 08:06:34 +0000
committerharti <harti@FreeBSD.org>2005-02-21 08:06:34 +0000
commitdd84d5412cf5d24c5d95740430e2123910c916bf (patch)
treeccff75f6427010b727da386006470fbabc7641b9 /usr.bin/make
parent34a89af278e7e0d74a62f08d5ab37b7e0727a449 (diff)
downloadFreeBSD-src-dd84d5412cf5d24c5d95740430e2123910c916bf.zip
FreeBSD-src-dd84d5412cf5d24c5d95740430e2123910c916bf.tar.gz
Fix a bug in handling archive members: when a member was not found
when looking into an already hashed archive, the code tried to use the name shortened to the maximum length allowed for the archive. Unfortunately it passed a buffer of junk to the hashing routine when the name actually wasn't too long. Theoretically this could lead to a false positive.
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/arch.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c
index 70c5d95..775e0b2 100644
--- a/usr.bin/make/arch.c
+++ b/usr.bin/make/arch.c
@@ -458,26 +458,22 @@ ArchStatMember(const char *archive, const char *member, Boolean hash)
ln = Lst_Find(&archives, archive, ArchFindArchive);
if (ln != NULL) {
+ char copy[AR_MAX_NAME_LEN + 1];
+
ar = Lst_Datum(ln);
he = Hash_FindEntry(&ar->members, member);
-
if (he != NULL) {
- return ((struct ar_hdr *)Hash_GetValue (he));
- } else {
- /* Try truncated name */
- char copy[AR_MAX_NAME_LEN + 1];
- size_t len = strlen(member);
-
- if (len > AR_MAX_NAME_LEN) {
- len = AR_MAX_NAME_LEN;
- strncpy(copy, member, AR_MAX_NAME_LEN);
- copy[AR_MAX_NAME_LEN] = '\0';
- }
- if ((he = Hash_FindEntry(&ar->members, copy)) != NULL)
- return (Hash_GetValue(he));
- return (NULL);
+ return (Hash_GetValue(he));
}
+
+ /* Try truncated name */
+ strncpy(copy, member, AR_MAX_NAME_LEN);
+ copy[AR_MAX_NAME_LEN] = '\0';
+
+ if ((he = Hash_FindEntry(&ar->members, copy)) != NULL)
+ return (Hash_GetValue(he));
+ return (NULL);
}
if (!hash) {
OpenPOWER on IntegriCloud