From eef0d1c9c56fb7c6733b716d36b08911639690dd Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 17 Feb 2017 20:01:42 +0100 Subject: [PATCH] libopkg: do not modify original version string in parse_version() The parse_version() function might be parsing the version string of another pkg_t instance so we must not modify it inplace to truncate the revision part, otherwise we will clobber the original version, leading to failing comparisations later on. Signed-off-by: Jo-Philipp Wich --- libopkg/pkg_parse.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libopkg/pkg_parse.c b/libopkg/pkg_parse.c index ae52deb..31e7309 100644 --- a/libopkg/pkg_parse.c +++ b/libopkg/pkg_parse.c @@ -84,12 +84,12 @@ int parse_version(pkg_t * pkg, const char *vstr) rev = strrchr(vstr, '-'); if (rev) { - *rev++ = '\0'; - pkg_set_string(pkg, PKG_REVISION, rev); + pkg_set_string(pkg, PKG_REVISION, rev + 1); + pkg_set_raw(pkg, PKG_VERSION, vstr, rev - vstr - 1); + } else { + pkg_set_string(pkg, PKG_VERSION, vstr); } - pkg_set_string(pkg, PKG_VERSION, vstr); - return 0; } -- 2.25.1