From fd8f39f1d54c3b56d16a494898e5a753e2c71715 Mon Sep 17 00:00:00 2001 From: Timo Teräs Date: Tue, 28 Feb 2023 14:39:09 +0200 Subject: version: fix leading zero stripping Only the leading zeroes should be ignored. Handle properly if the version component is actually zero. fixes #10880 --- src/version.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/version.c b/src/version.c index 4d227d0..b12cb7f 100644 --- a/src/version.c +++ b/src/version.c @@ -84,7 +84,7 @@ static int64_t get_token(int *type, apk_blob_t *blob) case TOKEN_DIGIT_OR_ZERO: /* Leading zero digits get a special treatment */ if (blob->ptr[i] == '0') { - while (i < blob->len && blob->ptr[i] == '0') + while (i+1 < blob->len && blob->ptr[i+1] == '0') i++; nt = TOKEN_DIGIT; v = -i; @@ -206,8 +206,8 @@ int apk_version_compare_blob_fuzzy(apk_blob_t a, apk_blob_t b, int fuzzy) bv = get_token(&bt, &b); #if 0 fprintf(stderr, - "av=%d, at=%d, a.len=%d\n" - "bv=%d, bt=%d, b.len=%d\n", + "av=%ld, at=%d, a.len=%ld\n" + "bv=%ld, bt=%d, b.len=%ld\n", av, at, a.len, bv, bt, b.len); #endif } -- cgit v1.2.3-70-g09d2