Blame SOURCES/0002-build-check-rich-dependencies-for-special-characters.patch

672c60
From e7fa1f1c1c4a6161c2254c761e857fdf04fba5ef Mon Sep 17 00:00:00 2001
672c60
Message-Id: <e7fa1f1c1c4a6161c2254c761e857fdf04fba5ef.1574338784.git.pmatilai@redhat.com>
672c60
In-Reply-To: <871065ddd493c76d80345d2e80b38b9ce4c7acdd.1574338784.git.pmatilai@redhat.com>
672c60
References: <871065ddd493c76d80345d2e80b38b9ce4c7acdd.1574338784.git.pmatilai@redhat.com>
672c60
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
672c60
Date: Wed, 21 Nov 2018 15:36:35 +0100
672c60
Subject: [PATCH 2/3] build: check rich dependencies for special characters
672c60
672c60
Reported-by: Michael Schroeder 
672c60
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
672c60
---
672c60
 build/pack.c | 30 +++++++++++++++++++++++++++---
672c60
 1 file changed, 27 insertions(+), 3 deletions(-)
672c60
672c60
diff --git a/build/pack.c b/build/pack.c
672c60
index daf878c76..c94964be2 100644
672c60
--- a/build/pack.c
672c60
+++ b/build/pack.c
672c60
@@ -228,12 +228,36 @@ exit:
672c60
     return rc;
672c60
 }
672c60
 
672c60
-static int haveTildeDep(Package pkg)
672c60
+struct charInDepData {
672c60
+    char c;
672c60
+    int present;
672c60
+};
672c60
+
672c60
+static rpmRC charInDepCb(void *cbdata, rpmrichParseType type,
672c60
+		const char *n, int nl, const char *e, int el, rpmsenseFlags sense,
672c60
+		rpmrichOp op, char **emsg) {
672c60
+    struct charInDepData *data = cbdata;
672c60
+    if (memchr(e, data->c, el))
672c60
+	data->present = 1;
672c60
+
672c60
+    return RPMRC_OK;
672c60
+}
672c60
+
672c60
+static int haveCharInDep(Package pkg, char c)
672c60
 {
672c60
+    struct charInDepData data = {c, 0};
672c60
     for (int i = 0; i < PACKAGE_NUM_DEPS; i++) {
672c60
 	rpmds ds = rpmdsInit(pkg->dependencies[i]);
672c60
 	while (rpmdsNext(ds) >= 0) {
672c60
-	    if (strchr(rpmdsEVR(ds), '~'))
672c60
+	    if (rpmdsIsRich(ds)) {
672c60
+		const char *depstr = rpmdsN(ds);
672c60
+		rpmrichParse(&depstr, NULL, charInDepCb, &data);
672c60
+	    } else {
672c60
+		const char *evr = rpmdsEVR(ds);
672c60
+		if (strchr(evr, c))
672c60
+		    data.present = 1;
672c60
+	    }
672c60
+	    if (data.present)
672c60
 		return 1;
672c60
 	}
672c60
     }
672c60
@@ -327,7 +351,7 @@ exit:
672c60
 static void finalizeDeps(Package pkg)
672c60
 {
672c60
     /* check if the package has a dependency with a '~' */
672c60
-    if (haveTildeDep(pkg))
672c60
+    if (haveCharInDep(pkg, '~'))
672c60
 	(void) rpmlibNeedsFeature(pkg, "TildeInVersions", "4.10.0-1");
672c60
 
672c60
     /* check if the package has a rich dependency */
672c60
-- 
672c60
2.23.0
672c60