Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libc/test/src/stdlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ add_header_library(
DEPENDS
libc.src.__support.CPP.type_traits
libc.src.__support.FPUtil.fp_bits
libc.src.__support.macros.properties.architectures
)

add_libc_test(
Expand Down
4 changes: 4 additions & 0 deletions libc/test/src/stdlib/StrfromTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/macros/properties/architectures.h"
#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
Expand Down Expand Up @@ -484,14 +485,17 @@ class StrfromTest : public LIBC_NAMESPACE::testing::ErrnoCheckingTest {
ASSERT_STREQ_LEN(written, buff, "-NAN");
}

// https://github.com/llvm/llvm-project/issues/166795
void charsWrittenOverflow(FunctionT func) {
#ifndef LIBC_TARGET_ARCH_IS_RISCV32
char buff[100];
// Trigger an overflow in the return value of strfrom by writing more than
// INT_MAX bytes.
int result = func(buff, sizeof(buff), "%.2147483647f", 1.0f);

EXPECT_LT(result, 0);
ASSERT_ERRNO_FAILURE();
#endif
}
};

Expand Down
Loading