summaryrefslogtreecommitdiff
path: root/src/version.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2021-10-25 13:29:41 +0300
committerTimo Teräs <timo.teras@iki.fi>2021-10-25 13:30:40 +0300
commit50ab589e9a5a84592ee4c0ac5a49506bb6c552fc (patch)
tree22e1a1402585e4bf0ab9fd6800c036fbd6701d1a /src/version.c
parentd38e2dd65a2286a65d83cbe3c6db244ab0ba9820 (diff)
downloadapk-tools-50ab589e9a5a84592ee4c0ac5a49506bb6c552fc.tar.gz
apk-tools-50ab589e9a5a84592ee4c0ac5a49506bb6c552fc.tar.bz2
apk-tools-50ab589e9a5a84592ee4c0ac5a49506bb6c552fc.tar.xz
apk-tools-50ab589e9a5a84592ee4c0ac5a49506bb6c552fc.zip
version: increase number of digits supported in version component
Report also version numbers as invalid if there's more than 18 digits. fixes #10774
Diffstat (limited to 'src/version.c')
-rw-r--r--src/version.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/version.c b/src/version.c
index 7c1c0b4..f93e4c5 100644
--- a/src/version.c
+++ b/src/version.c
@@ -68,11 +68,12 @@ static void next_token(int *type, apk_blob_t *blob)
*type = n;
}
-static int get_token(int *type, apk_blob_t *blob)
+static int64_t get_token(int *type, apk_blob_t *blob)
{
static const char *pre_suffixes[] = { "alpha", "beta", "pre", "rc" };
static const char *post_suffixes[] = { "cvs", "svn", "git", "hg", "p" };
- int v = 0, i = 0, nt = TOKEN_INVALID;
+ int i = 0, nt = TOKEN_INVALID;
+ int64_t v = 0;
if (blob->len <= 0) {
*type = TOKEN_END;
@@ -96,6 +97,7 @@ static int get_token(int *type, apk_blob_t *blob)
v *= 10;
v += blob->ptr[i++] - '0';
}
+ if (i >= 18) goto invalid;
break;
case TOKEN_LETTER:
v = blob->ptr[i++];
@@ -121,6 +123,7 @@ static int get_token(int *type, apk_blob_t *blob)
break;
/* fallthrough: invalid suffix */
default:
+ invalid:
*type = TOKEN_INVALID;
return -1;
}
@@ -200,7 +203,7 @@ int apk_version_validate(apk_blob_t ver)
int apk_version_compare_blob_fuzzy(apk_blob_t a, apk_blob_t b, int fuzzy)
{
int at = TOKEN_DIGIT, bt = TOKEN_DIGIT, tt;
- int av = 0, bv = 0;
+ int64_t av = 0, bv = 0;
if (APK_BLOB_IS_NULL(a) || APK_BLOB_IS_NULL(b)) {
if (APK_BLOB_IS_NULL(a) && APK_BLOB_IS_NULL(b))