[sanitizer] Support "bB" printf GLIBC extension (#128449)

https://www.gnu.org/software/libc/manual/html_node/Table-of-Output-Conversions.html

Without the patch llc triggers non-fatal Asan warning.
This commit is contained in:
Vitaly Buka 2025-02-23 18:46:52 -08:00 committed by GitHub
parent 3aef599d07
commit 8b1d38480b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View File

@ -67,6 +67,10 @@ static const char *maybe_parse_length_modifier(const char *p, char ll[2]) {
// Returns true if the character is an integer conversion specifier.
static bool format_is_integer_conv(char c) {
#if SANITIZER_GLIBC
if (char_is_one_of(c, "bB"))
return true;
#endif
return char_is_one_of(c, "diouxXn");
}

View File

@ -131,7 +131,6 @@ TEST(SanitizerCommonInterceptors, Scanf) {
testScanf("a%%%%b", 0);
testScanf("a%%b%%", 0);
testScanf("a%%%%%%b", 0);
testScanf("a%%%%%b", 0);
testScanf("a%%%%%f", 1, F);
testScanf("a%%%lxb", 1, L);
testScanf("a%lf%%%lxb", 2, D, L);
@ -207,6 +206,14 @@ TEST(SanitizerCommonInterceptors, Scanf) {
testScanfPartial("%d%n%n%d %s %s", 3, 5, I, I, I, I, test_buf_size);
testScanfPartial("%d%n%n%d %s %s", 4, 6, I, I, I, I, test_buf_size,
test_buf_size);
#if defined(__GLIBC__)
testScanf("%b", 1, I);
testScanf("%zb", 1, Z);
testScanf("a%%%%%b", 1, I);
#else
testScanf("a%%%%%b", 0);
#endif
}
TEST(SanitizerCommonInterceptors, ScanfAllocate) {