1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:17:44 +00:00

LibC: Fix missing '\n' at the end of ctime/ctime_r/asctime/asctime_r

@linusg noticed this bug in the original implementation during code review.
This makes all of these API's more spec conforming.
This commit is contained in:
Brian Gianforcaro 2021-04-20 16:26:12 -07:00 committed by Linus Groh
parent 440b81deba
commit df808f0ed3

View file

@ -193,7 +193,11 @@ char* asctime_r(const struct tm* tm, char* buffer)
{ {
// Spec states buffer must be at least 26 bytes. // Spec states buffer must be at least 26 bytes.
constexpr size_t assumed_len = 26; constexpr size_t assumed_len = 26;
strftime(buffer, assumed_len, "%a %b %e %T %Y", tm); size_t filled_size = strftime(buffer, assumed_len, "%a %b %e %T %Y\n", tm);
// Verify that the buffer was large enough.
VERIFY(filled_size != 0);
return buffer; return buffer;
} }