diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2008-04-29 15:08:47 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2008-04-29 15:08:47 +0300 |
commit | 010706ecbd4bdabc954fd9f4499a99772b92fea7 (patch) | |
tree | d1cbf4cf7aa396f24aaa329cb7ee14b20b0b8be2 /lib/legacy.c | |
parent | ba763344d4116912e616337f7a8c305a29c48c36 (diff) | |
download | rpm-010706ecbd4bdabc954fd9f4499a99772b92fea7.tar.gz rpm-010706ecbd4bdabc954fd9f4499a99772b92fea7.tar.bz2 rpm-010706ecbd4bdabc954fd9f4499a99772b92fea7.zip |
Allocate directory names on heap in compressFilelist()
Diffstat (limited to 'lib/legacy.c')
-rw-r--r-- | lib/legacy.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/legacy.c b/lib/legacy.c index ae6d7e03e..bfd83d9c3 100644 --- a/lib/legacy.c +++ b/lib/legacy.c @@ -32,7 +32,7 @@ void compressFilelist(Header h) HRE_t hre = (HRE_t)headerRemoveEntry; HFD_t hfd = headerFreeData; char ** fileNames; - const char ** dirNames; + char ** dirNames; const char ** baseNames; uint32_t * dirIndexes; rpmTagType fnt; @@ -63,7 +63,7 @@ void compressFilelist(Header h) if (fileNames[0][0] != '/') { /* HACK. Source RPM, so just do things differently */ dirIndex = 0; - dirNames[dirIndex] = ""; + dirNames[dirIndex] = xstrdup(""); for (i = 0; i < count; i++) { dirIndexes[i] = dirIndex; baseNames[i] = fileNames[i]; @@ -72,7 +72,7 @@ void compressFilelist(Header h) } for (i = 0; i < count; i++) { - const char ** needle; + char ** needle; char savechar; char * baseName; size_t len; @@ -86,9 +86,8 @@ void compressFilelist(Header h) *baseName = '\0'; if (dirIndex < 0 || (needle = bsearch(&fileNames[i], dirNames, dirIndex + 1, sizeof(dirNames[0]), dncmp)) == NULL) { - char *s = alloca(len + 1); - memcpy(s, fileNames[i], len + 1); - s[len] = '\0'; + char *s = xmalloc(len + 1); + rstrlcpy(s, fileNames[i], len + 1); dirIndexes[i] = ++dirIndex; dirNames[dirIndex] = s; } else @@ -108,6 +107,9 @@ exit: } fileNames = hfd(fileNames, fnt); + for (i = 0; i <= dirIndex; i++) { + free(dirNames[i]); + } free(dirNames); free(baseNames); free(dirIndexes); |