commit 5173a7a8452c5be229c1964f10f29903994302f6 from: Sergey Bronnikov via: Sergey Bronnikov date: Tue Jan 09 16:11:37 2024 UTC tests: add strftime(3) test commit - 78cf7a7b194e6cc517614cd52b19048398ef655d commit + 5173a7a8452c5be229c1964f10f29903994302f6 blob - /dev/null blob + 9c736bcb735e2b0e015b0bf7409c4a556974ce5b (mode 644) --- /dev/null +++ tests/strftime_test.cc @@ -0,0 +1,31 @@ +#include +#include +#include +#include + +#include + +extern "C" int +LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) +{ + FuzzedDataProvider fdp(Data, Size); + + struct tm tm = {0}; + tm.tm_sec = fdp.ConsumeIntegral(); + tm.tm_min = fdp.ConsumeIntegral(); + tm.tm_hour = fdp.ConsumeIntegral(); + tm.tm_mday = fdp.ConsumeIntegral(); + tm.tm_mon = fdp.ConsumeIntegral(); + tm.tm_year = fdp.ConsumeIntegral(); + tm.tm_wday = fdp.ConsumeIntegral(); + tm.tm_yday = fdp.ConsumeIntegral(); + tm.tm_isdst = fdp.ConsumeIntegral(); + + auto fmt = fdp.ConsumeRandomLengthString(); + size_t buf_len = fdp.ConsumeIntegral(); + + char buf[buf_len]; + strftime(buf, buf_len, fmt.c_str(), &tm); + + return 0; +}