summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorEdwin Groothuis <edwin@FreeBSD.org>2010-02-17 11:18:24 +0000
committerEdwin Groothuis <edwin@FreeBSD.org>2010-02-17 11:18:24 +0000
commit922ba8695f9afa9d07b21a861536528d84685941 (patch)
tree0651309ba5df24ab03c73f2b8948376df5ef690f /libc
parent77566d4b374e823f866d8adce69b12ee74a1de1a (diff)
Diffstat (limited to 'libc')
-rw-r--r--libc/stdtime/asctime.c13
-rw-r--r--libc/stdtime/localtime.c15
2 files changed, 19 insertions, 9 deletions
diff --git a/libc/stdtime/asctime.c b/libc/stdtime/asctime.c
index e0804f16f4dd..52586c6aedf2 100644
--- a/libc/stdtime/asctime.c
+++ b/libc/stdtime/asctime.c
@@ -11,7 +11,7 @@
#ifndef lint
#ifndef NOID
-static char elsieid[] = "@(#)asctime.c 8.2";
+static char elsieid[] = "@(#)asctime.c 8.5";
#endif /* !defined NOID */
#endif /* !defined lint */
@@ -91,6 +91,10 @@ char * buf;
char year[INT_STRLEN_MAXIMUM(int) + 2];
char result[MAX_ASCTIME_BUF_SIZE];
+ if (timeptr == NULL) {
+ errno = EINVAL;
+ return strcpy(buf, "??? ??? ?? ??:??:?? ????\n");
+ }
if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK)
wn = "???";
else wn = wday_name[timeptr->tm_wday];
@@ -113,10 +117,9 @@ char * buf;
timeptr->tm_mday, timeptr->tm_hour,
timeptr->tm_min, timeptr->tm_sec,
year);
- if (strlen(result) < STD_ASCTIME_BUF_SIZE || buf == buf_asctime) {
- (void) strcpy(buf, result);
- return buf;
- } else {
+ if (strlen(result) < STD_ASCTIME_BUF_SIZE || buf == buf_asctime)
+ return strcpy(buf, result);
+ else {
#ifdef EOVERFLOW
errno = EOVERFLOW;
#else /* !defined EOVERFLOW */
diff --git a/libc/stdtime/localtime.c b/libc/stdtime/localtime.c
index d186080bf351..255ff4828a52 100644
--- a/libc/stdtime/localtime.c
+++ b/libc/stdtime/localtime.c
@@ -5,7 +5,7 @@
#ifndef lint
#ifndef NOID
-static char elsieid[] = "@(#)localtime.c 8.9";
+static char elsieid[] = "@(#)localtime.c 8.10";
#endif /* !defined NOID */
#endif /* !defined lint */
@@ -1889,6 +1889,10 @@ const long offset;
int types[TZ_MAX_TYPES];
int okay;
+ if (tmp == NULL) {
+ errno = EINVAL;
+ return WRONG;
+ }
if (tmp->tm_isdst > 1)
tmp->tm_isdst = 1;
t = time2(tmp, funcp, offset, &okay);
@@ -1960,7 +1964,8 @@ time_t
timelocal(tmp)
struct tm * const tmp;
{
- tmp->tm_isdst = -1; /* in case it wasn't initialized */
+ if (tmp != NULL)
+ tmp->tm_isdst = -1; /* in case it wasn't initialized */
return mktime(tmp);
}
@@ -1968,7 +1973,8 @@ time_t
timegm(tmp)
struct tm * const tmp;
{
- tmp->tm_isdst = 0;
+ if (tmp != NULL)
+ tmp->tm_isdst = 0;
return time1(tmp, gmtsub, 0L);
}
@@ -1977,7 +1983,8 @@ timeoff(tmp, offset)
struct tm * const tmp;
const long offset;
{
- tmp->tm_isdst = 0;
+ if (tmp != NULL)
+ tmp->tm_isdst = 0;
return time1(tmp, gmtsub, offset);
}