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 #1459]
* time/asctime.c (__asctime_r): Check for tm_year computation to overflow and fail in this case. * time/Makefile (tests): Add bug-asctime. * time/bug-asctime.c: New file.
- Loading branch information
Ulrich Drepper
committed
Oct 14, 2005
1 parent
93c6cb8
commit 576c845
Showing
4 changed files
with
55 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#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 = INT_MAX; | ||
errno = 0; | ||
char *s = asctime (tp); | ||
if (s != NULL || errno != EOVERFLOW) | ||
{ | ||
puts ("asctime did not fail correctly"); | ||
result = 1; | ||
} | ||
char buf[1000]; | ||
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" |