From: Jo-Philipp Wich Date: Fri, 17 Feb 2017 19:01:42 +0000 (+0100) Subject: libopkg: do not modify original version string in parse_version() X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=eef0d1c9c56fb7c6733b716d36b08911639690dd;p=oweals%2Fopkg-lede.git 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 --- 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; }