From 5e94633660d0e2b970bf42f1dc24346ed46cae2e Mon Sep 17 00:00:00 2001 From: Lubos Kardos Date: Fri, 23 Oct 2015 14:21:58 +0200 Subject: [PATCH] Make terminating build if version format is wrong configurable --- build/parseReqs.c | 14 +++++++++----- macros.in | 3 +++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/build/parseReqs.c b/build/parseReqs.c index acdfeb9e00..a443505e41 100644 --- a/build/parseReqs.c +++ b/build/parseReqs.c @@ -21,6 +21,7 @@ static rpmRC checkSep(const char *s, char c, char **emsg) const char *sep = strchr(s, c); if (sep && strchr(sep + 1, c)) { rasprintf(emsg, "Invalid version (double separator '%c'): %s", c, s); + return RPMRC_FAIL; } return RPMRC_OK; } @@ -35,7 +36,7 @@ static rpmRC checkEpoch(const char *s, char **emsg) for (si = s; si != sep; si++) { if (!risdigit(*si)) { rasprintf(emsg, "Invalid version (epoch must be unsigned integer): %s", s); - break; + return RPMRC_FAIL; } } return RPMRC_OK; @@ -58,10 +59,13 @@ static rpmRC checkDep(rpmSpec spec, char *N, char *EVR, char **emsg) } if (rpmCharCheck(spec, EVR, ".-_+:%{}~")) return RPMRC_FAIL; - if (checkSep(EVR, '-', emsg) != RPMRC_OK || checkSep(EVR, ':', emsg) != RPMRC_OK) - return RPMRC_FAIL; - if (checkEpoch(EVR, emsg) != RPMRC_OK) - return RPMRC_FAIL; + if (checkSep(EVR, '-', emsg) != RPMRC_OK || + checkSep(EVR, ':', emsg) != RPMRC_OK || + checkEpoch(EVR, emsg) != RPMRC_OK) { + + if (rpmExpandNumeric("%{?_wrong_version_format_terminate_build}")) + return RPMRC_FAIL; + } } return RPMRC_OK; } diff --git a/macros.in b/macros.in index 9ffe4a84a6..6ea04c9d60 100644 --- a/macros.in +++ b/macros.in @@ -401,6 +401,9 @@ package or when debugging this package.\ # Should invalid utf8 encoding in package metadata terminate a build? %_invalid_encoding_terminates_build 0 +# Should invalid version format in requires, provides, ... terminate a build? +%_wrong_version_format_terminate_build 1 + # # Should rpm try to download missing sources at build-time? # Enabling this is dangerous as long as rpm has no means to validate