summaryrefslogtreecommitdiff
path: root/lib/legacy.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-01-02 16:18:55 +0200
committerPanu Matilainen <pmatilai@redhat.com>2008-01-02 16:18:55 +0200
commitbb70bbb7734a2a069bf97b08a354e04fb3debfdf (patch)
tree7bb8b64b70e6f93a6fee0d0ea54df4d08dde6981 /lib/legacy.c
parent505e8c352cdcd389b014e2276df30fb06e5984cd (diff)
downloadrpm-bb70bbb7734a2a069bf97b08a354e04fb3debfdf.tar.gz
rpm-bb70bbb7734a2a069bf97b08a354e04fb3debfdf.tar.bz2
rpm-bb70bbb7734a2a069bf97b08a354e04fb3debfdf.zip
Avoid compressFilelist() stack overflow in pathological cases
- allocate dirNames etc arrays on heap, not stack - the arrays can be rather large and alloca isn't very friendly when it fails...
Diffstat (limited to 'lib/legacy.c')
-rw-r--r--lib/legacy.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/legacy.c b/lib/legacy.c
index a856c4e26..704af5aaa 100644
--- a/lib/legacy.c
+++ b/lib/legacy.c
@@ -54,9 +54,9 @@ void compressFilelist(Header h)
if (fileNames == NULL || count <= 0)
return;
- dirNames = alloca(sizeof(*dirNames) * count); /* worst case */
- baseNames = alloca(sizeof(*dirNames) * count);
- dirIndexes = alloca(sizeof(*dirIndexes) * count);
+ dirNames = xmalloc(sizeof(*dirNames) * count); /* worst case */
+ baseNames = xmalloc(sizeof(*dirNames) * count);
+ dirIndexes = xmalloc(sizeof(*dirIndexes) * count);
if (fileNames[0][0] != '/') {
/* HACK. Source RPM, so just do things differently */
@@ -106,6 +106,9 @@ exit:
}
fileNames = hfd(fileNames, fnt);
+ free(dirNames);
+ free(baseNames);
+ free(dirIndexes);
xx = hre(h, RPMTAG_OLDFILENAMES);
}