X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_date_api.c;h=78a5da1938da7935a83acf587c4b6ccfe1ecaffd;hp=66033262bbc3ba5f73e3bb7a0d1b951aaaf0e87a;hb=refs%2Fheads%2Fv1.7.x;hpb=fed554c3b8ad4c438be77b35bed5bf6b8edfcf71 diff --git a/http_date_api.c b/http_date_api.c index 6603326..78a5da1 100644 --- a/http_date_api.c +++ b/http_date_api.c @@ -6,7 +6,7 @@ | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ - | Copyright (c) 2004-2006, Michael Wallner | + | Copyright (c) 2004-2010, Michael Wallner | +--------------------------------------------------------------------+ */ @@ -141,20 +141,20 @@ static inline int check_tzone(const char *tzone) /* {{{ char *http_date(time_t) */ PHP_HTTP_API char *_http_date(time_t t TSRMLS_DC) { - struct tm *gmtime, tmbuf; + char *date = NULL; + struct tm *gmtime = NULL, tmbuf; + memset(&tmbuf, 0, sizeof(tmbuf)); if ((gmtime = php_gmtime_r(&t, &tmbuf))) { - char *date = ecalloc(1, 31); - snprintf(date, 30, + spprintf(&date, 0, "%s, %02d %s %04d %02d:%02d:%02d GMT", days[gmtime->tm_wday], gmtime->tm_mday, months[gmtime->tm_mon], gmtime->tm_year + 1900, gmtime->tm_hour, gmtime->tm_min, gmtime->tm_sec ); - return date; } - return NULL; + return date; } /* }}} */