From 27de1e8a0c44ff7fd04d4edc4cd5f48ebe39c2c6 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sun, 28 Dec 2008 11:13:17 +0100 Subject: [PATCH] xbps_unpack_archive_cb: alloc buf from heap memory instead. --HG-- extra : convert_revision : dfbcbfeab3e57b571388447565ca0156816e7a84 --- lib/install.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/install.c b/lib/install.c index 08e8b3fc9d..167a4fe140 100644 --- a/lib/install.c +++ b/lib/install.c @@ -264,7 +264,8 @@ int xbps_unpack_archive_cb(struct archive *ar, const char *pkgname) { struct archive_entry *entry; - char buf[PATH_MAX]; + size_t len; + char *buf; int rv = 0, flags; bool actgt = false; @@ -273,9 +274,20 @@ xbps_unpack_archive_cb(struct archive *ar, const char *pkgname) else flags = 0; - if (snprintf(buf, sizeof(buf) - 1, ".%s/metadata/%s/prepost-action.sh", - XBPS_META_PATH, pkgname) < 0) + /* + * This length is '.%s/metadata/%s/prepost-action.sh' not + * including nul. + */ + len = strlen(XBPS_META_PATH) + strlen(pkgname) + 29; + buf = malloc(len + 1); + if (buf == NULL) + return ENOMEM; + + if (snprintf(buf, len + 1, ".%s/metadata/%s/prepost-action.sh", + XBPS_META_PATH, pkgname) < 0) { + free(buf); return -1; + } while (archive_read_next_header(ar, &entry) == ARCHIVE_OK) { /* @@ -322,6 +334,8 @@ xbps_unpack_archive_cb(struct archive *ar, const char *pkgname) } } + free(buf); + return rv; }