diff options
author | 2022-06-15 21:53:43 +0200 | |
---|---|---|
committer | 2022-06-15 21:53:43 +0200 | |
commit | 62503bbd9e82a5b0fdeec6e357a95e724ec3cef6 (patch) | |
tree | af33dc020e1d91eb1c4d7bb328e39fd10ddc234c /libq | |
parent | main: ensure correct parsing of key-value pairs in ini-files (diff) | |
download | portage-utils-62503bbd9e82a5b0fdeec6e357a95e724ec3cef6.tar.gz portage-utils-62503bbd9e82a5b0fdeec6e357a95e724ec3cef6.tar.bz2 portage-utils-62503bbd9e82a5b0fdeec6e357a95e724ec3cef6.zip |
libq/atom: fix atom_compare for "0" version componentsv0.94.1
Bug: https://bugs.gentoo.org/852197
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Diffstat (limited to 'libq')
-rw-r--r-- | libq/atom.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/libq/atom.c b/libq/atom.c index 50e9520c..31299f1b 100644 --- a/libq/atom.c +++ b/libq/atom.c @@ -784,22 +784,38 @@ atom_compare_flg(const depend_atom *data, const depend_atom *query, int flags) *ends1 != '_'; ends1++) ; + if (ends1 != s1) + ends1--; for (ends2 = s2; *ends2 != '\0' && *ends2 != '.' && *ends2 != '_'; ends2++) ; - /* 3.3L2-3: remove *trailing* zeros */ - for (ends1--; ends1 > s1 && *ends1 == '0'; ends1--) - ; - for (ends2--; ends2 > s2 && *ends2 == '0'; ends2--) - ; - /* 3.3L4 ASCII stringwise comparison */ - n1 = ends1 - s1; - n2 = ends2 - s2; - n1 = strncmp(s1, s2, n1 > n2 ? n1 : n2); - n2 = 0; + if (ends2 != s2) + ends2--; + /* bug 852197: leading 0 means something else + * must follow */ + if (ends1 - s1 > 1 || ends2 - s2 > 1) { + /* 3.3L2-3: remove *trailing* zeros */ + for (; ends1 > s1 && *ends1 == '0'; ends1--) + ; + for (; ends2 > s2 && *ends2 == '0'; ends2--) + ; + /* 3.3L4 ASCII stringwise comparison */ + n1 = ends1 - s1; + n2 = ends2 - s2; + n1 = strncmp(s1, s2, n1 > n2 ? n1 : n2); + n2 = 0; + } else { + /* repeat of 3.3#L9 (else case below) */ + n1 = strtoll(s1, &ends1, 10); + if (ends1 == s1) + n1 = -1; + n2 = strtoll(s2, &ends2, 10); + if (ends2 == s2) + n2 = -1; + } } else { /* 3.3#L9 */ n1 = strtoll(s1, &ends1, 10); if (ends1 == s1) |