diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2016-10-25 15:14:39 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2017-10-26 10:40:47 +0300 |
commit | 12fc3389fcfb037e54e3a0054d40cff5ef7354d2 (patch) | |
tree | fcd589be50c8b3ca100a247e5c8fed219ef3ab81 | |
parent | daaef890f8fa0d2e20f72eb068505d64902e9de4 (diff) | |
download | rpm-12fc3389fcfb037e54e3a0054d40cff5ef7354d2.tar.gz |
Fix segfault on wrong datatype passed to shescapeFormat
Check for string class explicitly, treat others as errors.
(cherry picked from commit f38bf589bf0bfe90540a51c3da9a516f1c53c0e5)
-rw-r--r-- | lib/formats.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/formats.c b/lib/formats.c index c0427a616..f1fb8717b 100644 --- a/lib/formats.c +++ b/lib/formats.c @@ -150,7 +150,7 @@ static char * shescapeFormat(rpmtd td) if (rpmtdClass(td) == RPM_NUMERIC_CLASS) { rasprintf(&result, "%" PRIu64, rpmtdGetNumber(td)); - } else { + } else if (rpmtdClass(td) == RPM_STRING_CLASS) { char *buf = xstrdup(rpmtdGetString(td));; result = dst = xmalloc(strlen(buf) * 4 + 3); @@ -168,6 +168,8 @@ static char * shescapeFormat(rpmtd td) *dst++ = '\''; *dst = '\0'; free(buf); + } else { + result = xstrdup(_("(invalid type)")); } return result; |