diff options
author | Michael Schroeder <mls@suse.de> | 2022-06-22 14:07:01 +0200 |
---|---|---|
committer | Michal Domonkos <mdomonko@redhat.com> | 2022-07-01 10:52:14 +0200 |
commit | 1527e122c6c49638852133327e8a8bfab5d99dc7 (patch) | |
tree | 72daf56dfd153dbeb581bfa9576245380b48c0a7 | |
parent | 6910974c7a2a2deff157b0960af9a794b6b61d81 (diff) | |
download | rpm-1527e122c6c49638852133327e8a8bfab5d99dc7.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.c | 2 | ||||
-rw-r--r-- | tests/rpmmacro.at | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/rpmio/expression.c b/rpmio/expression.c index ccd0e26f7..8d0faeb3a 100644 --- a/rpmio/expression.c +++ b/rpmio/expression.c @@ -454,7 +454,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 a26f42d5a..aab94d1eb 100644 --- a/tests/rpmmacro.at +++ b/tests/rpmmacro.at @@ -515,6 +515,7 @@ runroot rpm \ --eval '%["%{aaa}"]' \ --eval '%[%{?ccc}]' \ --eval '%[v"1:2.3-4"]' \ + --eval '%[v"0" && v"0"]' \ ]], [0], [4096 @@ -524,6 +525,7 @@ runroot rpm \ 5 0 1:2.3-4 +0 ], []) AT_CLEANUP |