Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[BZ #1460]
* time/asctime.c (asctime_internal): New function, derived from asctime_r. Takes additional parameter which is the buffer length. Use snprintf instead sprintf, if it overflows, fail. (asctime_r): Call asctime_internal with 26 as buffer length. (asctime): Call asctime_internal with length of internal buffer. * time/Makefile (tests): Add bug-asctime_r. * time/bug-asctime_r.c: New file.
- Loading branch information
Ulrich Drepper
committed
Oct 14, 2005
1 parent
576c845
commit ce98231
Showing
5 changed files
with
69 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <errno.h> | ||
#include <limits.h> | ||
#include <stdio.h> | ||
#include <time.h> | ||
|
||
|
||
static int | ||
do_test (void) | ||
{ | ||
int result = 0; | ||
time_t t = time (NULL); | ||
struct tm *tp = localtime (&t); | ||
tp->tm_year = 10000 - 1900; | ||
char buf[1000]; | ||
errno = 0; | ||
char *s = asctime_r (tp, buf); | ||
if (s != NULL || errno != EOVERFLOW) | ||
{ | ||
puts ("asctime_r did not fail correctly"); | ||
result = 1; | ||
} | ||
return result; | ||
} | ||
|
||
#define TEST_FUNCTION do_test () | ||
#include "../test-skeleton.c" |