]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
lib: add more string to 64-bit integer conversion overflow tests
authorDmitry Antipov <dmantipov@yandex.ru>
Tue, 19 May 2026 17:22:54 +0000 (20:22 +0300)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 29 May 2026 04:24:50 +0000 (21:24 -0700)
Add a few more string to 64-bit integer conversion tests to check whether
'kstrtoull()', 'kstrtoll()', 'kstrtou64()' and 'kstrtos64()' can handle
overflows reported by '_parse_integer_limit()'.

Link: https://lore.kernel.org/20260519172259.908980-4-dmantipov@yandex.ru
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Charlie Jenkins <thecharlesjenkins@gmail.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/test-kstrtox.c

index ee87fef66cb58e8710b3674ade7055b646048db5..811128d0df16f7b8540d2dfce60ddb4814d8eb25 100644 (file)
@@ -198,6 +198,7 @@ static void __init test_kstrtoull_fail(void)
                {"10000000000000000000000000000000000000000000000000000000000000000",   2},
                {"2000000000000000000000",      8},
                {"18446744073709551616",        10},
+               {"569202370375329612767",       10},
                {"10000000000000000",   16},
                /* negative */
                {"-0", 0},
@@ -275,9 +276,11 @@ static void __init test_kstrtoll_fail(void)
                {"9223372036854775809", 10},
                {"18446744073709551614",        10},
                {"18446744073709551615",        10},
+               {"569202370375329612767",       10},
                {"-9223372036854775809",        10},
                {"-18446744073709551614",       10},
                {"-18446744073709551615",       10},
+               {"-569202370375329612767",      10},
                /* sign is first character if any */
                {"-+1", 0},
                {"-+1", 8},
@@ -334,6 +337,7 @@ static void __init test_kstrtou64_fail(void)
                {"-1",  10},
                {"18446744073709551616",        10},
                {"18446744073709551617",        10},
+               {"569202370375329612767",       10},
        };
        TEST_FAIL(kstrtou64, u64, "%llu", test_u64_fail);
 }
@@ -386,6 +390,8 @@ static void __init test_kstrtos64_fail(void)
                {"18446744073709551615",        10},
                {"18446744073709551616",        10},
                {"18446744073709551617",        10},
+               {"569202370375329612767",       10},
+               {"-569202370375329612767",      10},
        };
        TEST_FAIL(kstrtos64, s64, "%lld", test_s64_fail);
 }