mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 03:27:30 -04:00
lib: add more string to 64-bit integer conversion overflow tests
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>
This commit is contained in:
committed by
Andrew Morton
parent
9a4580db6e
commit
ab90fc1007
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user