summaryrefslogtreecommitdiff
path: root/build/parseDescription.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2019-08-14 15:58:30 +0300
committerPanu Matilainen <pmatilai@redhat.com>2019-08-19 12:56:20 +0300
commit99b9ded5dd7d1118aea528600fcf20ba89dbab9b (patch)
tree58e9a426228b5611f16e7bf1deb2a2547cc76b8f /build/parseDescription.c
parent7faf8eda1358f8a877b9b3d6e1197b814e80b50b (diff)
downloadrpm-99b9ded5dd7d1118aea528600fcf20ba89dbab9b.tar.gz
Fix segfault regression on empty script or description at end of spec
More ripples from the parseLines() unification (commits 91e8d826e473c98209ba9db0ea06ab884557076c to 783e2dc0b424afdf0a5d2add368279cb63016897), the callers used to explicitly allocate an empty string buffer, but with lazy allocation from parseLines() they're getting NULL in the special circumstance of being last in the spec, and no "body". Specifically this happens with empty %description or scriptlet without a body, eg "%post -p /sbin/ldconfig". The script regression report + reproducer and a preliminary patch originally from RhBug:1732276 by nvwarr.
Diffstat (limited to 'build/parseDescription.c')
-rw-r--r--build/parseDescription.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/build/parseDescription.c b/build/parseDescription.c
index 2b255b514..c0737c09c 100644
--- a/build/parseDescription.c
+++ b/build/parseDescription.c
@@ -21,6 +21,7 @@ int parseDescription(rpmSpec spec)
const char **argv = NULL;
const char *name = NULL;
const char *lang = RPMBUILD_DEFAULT_LANG;
+ const char *descr = "";
poptContext optCon = NULL;
struct poptOption optionsTable[] = {
{ NULL, 'n', POPT_ARG_STRING, &name, 'n', NULL, NULL},
@@ -68,9 +69,13 @@ int parseDescription(rpmSpec spec)
goto exit;
}
- stripTrailingBlanksStringBuf(sb);
+ if (sb) {
+ stripTrailingBlanksStringBuf(sb);
+ descr = getStringBuf(sb);
+ }
+
if (addLangTag(spec, pkg->header,
- RPMTAG_DESCRIPTION, getStringBuf(sb), lang)) {
+ RPMTAG_DESCRIPTION, descr, lang)) {
nextPart = PART_ERROR;
}