[Rpm-maint] [PATCH] Check provides/requires parsing so that bad E:V-R are not accepted anymore.

james at fedoraproject.org james at fedoraproject.org
Mon Nov 18 14:11:14 UTC 2013


From: James Antill <james at and.org>

---
 build/parseReqs.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/build/parseReqs.c b/build/parseReqs.c
index 36db460..609d379 100644
--- a/build/parseReqs.c
+++ b/build/parseReqs.c
@@ -40,6 +40,7 @@ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTagVal tagN,
 {
     const char *r, *re, *v, *ve;
     const char *emsg = NULL;
+    const char *sep = NULL;
     char * N = NULL, * EVR = NULL;
     rpmTagVal nametag = RPMTAG_NOT_FOUND;
     rpmsenseFlags Flags;
@@ -154,6 +155,22 @@ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTagVal tagN,
 	    EVR = xmalloc((ve-v) + 1);
 	    rstrlcpy(EVR, v, (ve-v) + 1);
 	    if (rpmCharCheck(spec, EVR, ve-v, ".-_+:%{}~")) goto exit;
+
+            /* While ':' and '-' are valid, only one of each is valid. */
+            sep = strchr(EVR, '-');
+            if (sep && strchr(sep+1, '-')) {
+                rpmlog(RPMLOG_ERR, _("line %d: Double separator '%c' in: %s\n"),
+                       spec->lineNum, '-', spec->line);
+                goto exit;
+            }
+
+            sep = strchr(EVR, ':');
+            if (sep && strchr(sep+1, ':')) {
+                rpmlog(RPMLOG_ERR, _("line %d: Double separator '%c' in: %s\n"),
+                       spec->lineNum, ':', spec->line);
+                goto exit;
+            }
+
 	    re = ve;	/* ==> next token after EVR string starts here */
 	} else
 	    EVR = NULL;
-- 
1.7.7.6



More information about the Rpm-maint mailing list