diff options
author | Fabian Groffen <grobian@gentoo.org> | 2017-12-28 17:12:54 +0100 |
---|---|---|
committer | Fabian Groffen <grobian@gentoo.org> | 2017-12-28 17:12:54 +0100 |
commit | e5ed806b4a2784ced621efd8c5b036bddef780f8 (patch) | |
tree | 36e37d99673b4d042b79ebf44db1e853bb730625 | |
parent | tests: add test for bug #638816 (diff) | |
download | portage-utils-e5ed806b4a2784ced621efd8c5b036bddef780f8.tar.gz portage-utils-e5ed806b4a2784ced621efd8c5b036bddef780f8.tar.bz2 portage-utils-e5ed806b4a2784ced621efd8c5b036bddef780f8.zip |
atom_explode: be more careful with eating suffix letters
Make sure we don't just eat a char at the end of the atom, because if
that char appears after a -, it will be seen as version part. An
example is xerces-c, where the parsed atom form would just be xerces.
Bug: https://bugs.gentoo.org/638816
-rw-r--r-- | libq/atom_explode.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libq/atom_explode.c b/libq/atom_explode.c index 956ac49..057bfa1 100644 --- a/libq/atom_explode.c +++ b/libq/atom_explode.c @@ -218,9 +218,12 @@ atom_explode(const char *atom) ret->suffixes[idx] = t; } - /* allow for 1 optional suffix letter */ + /* allow for 1 optional suffix letter, must be following a number + * otherwise we eat stuff like -c, see bug #639978 */ ptr = ret->PN + strlen(ret->PN); - if (ptr[-1] >= 'a' && ptr[-1] <= 'z') { + if (ptr[-1] >= 'a' && ptr[-1] <= 'z' && + ptr - 2 > ret->PN && ptr[-2] >= '0' && ptr[-2] <= '9') + { ret->letter = ptr[-1]; --ptr; } |