summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2022-06-22 14:07:01 +0200
committerPanu Matilainen <pmatilai@redhat.com>2022-06-28 14:51:02 +0300
commitae18b24f5096bf756553286024473a651c8258a9 (patch)
tree0c53a901c79832862604c776e80c80fd89473f84
parentc733877b8fc136a25738be446cd1c7a9db4749f2 (diff)
downloadrpm-ae18b24f5096bf756553286024473a651c8258a9.tar.gz
Fix short circuiting of version strings in expressions
We use an empty string when discarding a value due to short circuiting, but an empty string is not allowed for versions. So use "0" in that case. Fixes: #1883 (cherry picked from commit 321933f060896f721e361a1c8a8d3731bdcee827)
-rw-r--r--rpmio/expression.c2
-rw-r--r--tests/rpmmacro.at2
2 files changed, 3 insertions, 1 deletions
diff --git a/rpmio/expression.c b/rpmio/expression.c
index a389a04d5..98a44bbdb 100644
--- a/rpmio/expression.c
+++ b/rpmio/expression.c
@@ -477,7 +477,7 @@ static int rdToken(ParseState state)
if (qtok == TOK_STRING) {
v = valueMakeString(temp);
} else {
- v = valueMakeVersion(temp);
+ v = valueMakeVersion(state->flags & RPMEXPR_DISCARD ? "0" : temp);
free(temp); /* version doesn't take ownership of the string */
if (v == 0) {
exprErr(state, _("invalid version"), p+1);
diff --git a/tests/rpmmacro.at b/tests/rpmmacro.at
index d1490b4d9..c4376d49e 100644
--- a/tests/rpmmacro.at
+++ b/tests/rpmmacro.at
@@ -533,6 +533,7 @@ runroot rpm \
--eval '%["%{aaa}"]' \
--eval '%[%{?ccc}]' \
--eval '%[v"1:2.3-4"]' \
+ --eval '%[v"0" && v"0"]' \
]],
[0],
[4096
@@ -542,6 +543,7 @@ runroot rpm \
5
0
1:2.3-4
+0
],
[])
AT_CLEANUP