summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwang biao <biao716.wang@samsung.com>2023-06-14 14:44:10 +0800
committerwang biao <biao716.wang@samsung.com>2023-06-14 14:44:13 +0800
commitf33b6fc7c4360b6df83e276230f0062fc6c9d823 (patch)
treeb7a5eb12228d0ff44592fd167d706849a3ee17da
parent52fdf747b37d00f7c879e69772c2422139108206 (diff)
downloadrpm-f33b6fc7c4360b6df83e276230f0062fc6c9d823.tar.gz
rpm-f33b6fc7c4360b6df83e276230f0062fc6c9d823.tar.bz2
rpm-f33b6fc7c4360b6df83e276230f0062fc6c9d823.zip
fix rpm crash issue when there is multiple %files section in spec filesubmit/tizen_base/20230613.141030accepted/tizen/base/tool/20230619.044911
when writing multiple %files, it means they are packing for main package, the variable will be NULL. It will happen segment fault at strncmp function. Change-Id: I3e5bd6f9e1cb774b4d7f97a9f6522d66361009b8 Signed-off-by: wang biao <biao716.wang@samsung.com>
-rw-r--r--build/parseFiles.c2
-rw-r--r--build/parsePreamble.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/build/parseFiles.c b/build/parseFiles.c
index 29fd637e9..d2ea9e3d1 100644
--- a/build/parseFiles.c
+++ b/build/parseFiles.c
@@ -72,7 +72,7 @@ int parseFiles(rpmSpec spec)
if (pkg->fileList != NULL) {
rpmlog(RPMLOG_WARNING, _("line %d: multiple %%files for package '%s'\n"),
spec->lineNum, rpmstrPoolStr(pkg->pool, pkg->name));
- if (0 == strncmp(name, "debuginfo", 9))
+ if ((name != NULL) && (0 == strncmp(name, "debuginfo", 9)))
{
char* multifilelist_flag = "1";
headerPutString(pkg->header, RPMTAG_MULTIFILELIST, multifilelist_flag);
diff --git a/build/parsePreamble.c b/build/parsePreamble.c
index 70c528ad1..cb97a5d8e 100644
--- a/build/parsePreamble.c
+++ b/build/parsePreamble.c
@@ -1129,7 +1129,7 @@ int parsePreamble(rpmSpec spec, int initialPackage)
if (!lookupPackage(spec, name, flag, NULL)) {
//exist %package debuginfo, need to ignore it, because there has been
//debuginfo package created by %debug_package macro.
- if (0 == strncmp(name, "debuginfo", 9))
+ if ((name != NULL) && (0 == strncmp(name, "debuginfo", 9)))
{
rpmlog(RPMLOG_WARNING, _("debuginfo package has been in spec file, Don't write again this %s"), spec->line);
if ((rc = readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS)) > 0) {