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