SHA256
3
0
forked from pool/rpm
rpm/emptyfilelist.diff

17 lines
568 B
Diff

Fix segfault when rpmbuild stumbles over an empty file list.
The "+ 1" is a remedy for xmalloc(0), which would return NULL.
Index: ./build/files.c
===================================================================
--- ./build/files.c
+++ ./build/files.c
@@ -1380,7 +1380,7 @@ static void genCpioListAndHeader(/*@part
: (int *)(fi->bnl + fi->fc);
/*@=dependenttrans@*/
- fi->apath = xmalloc(fi->fc * sizeof(*fi->apath) + apathlen);
+ fi->apath = xmalloc(fi->fc * sizeof(*fi->apath) + apathlen + 1);
a = (char *)(fi->apath + fi->fc);
*a = '\0';