summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2010-02-01 14:55:53 +0000
committerIgor Sysoev <igor@sysoev.ru>2010-02-01 14:55:53 +0000
commit82f12f79110b9a66c5ff5574f7156b67d0f2d462 (patch)
tree5d8d9611a32cea189ee4179b224f43b7a99a77b3 /src
parentaf7e5336829540d80490fc4fa7153ce2efb95954 (diff)
downloadnginx-82f12f79110b9a66c5ff5574f7156b67d0f2d462.tar.gz
nginx-82f12f79110b9a66c5ff5574f7156b67d0f2d462.tar.bz2
merge r3208, r3209:
ngx_http_parse_time() fixes: *) use ngx_uint_t instead of int, strange to say this reduce function size by 16 bytes *) ngx_http_parse_time() should support full 32-bit time
Diffstat (limited to 'src')
-rw-r--r--src/http/ngx_http_parse_time.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/http/ngx_http_parse_time.c b/src/http/ngx_http_parse_time.c
index 23fc23854..2e7b40add 100644
--- a/src/http/ngx_http_parse_time.c
+++ b/src/http/ngx_http_parse_time.c
@@ -8,13 +8,15 @@
#include <ngx_core.h>
-static int mday[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+static ngx_uint_t mday[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
time_t
ngx_http_parse_time(u_char *value, size_t len)
{
- u_char *p, *end;
- int day, month, year, hour, min, sec;
+ u_char *p, *end;
+ ngx_int_t month;
+ ngx_uint_t day, year, hour, min, sec;
+ uint64_t time;
enum {
no = 0,
rfc822, /* Tue, 10 Nov 2002 23:50:13 */
@@ -229,14 +231,6 @@ ngx_http_parse_time(u_char *value, size_t len)
return NGX_ERROR;
}
-#if (NGX_TIME_T_SIZE <= 4)
-
- if (year >= 2038) {
- return NGX_ERROR;
- }
-
-#endif
-
/*
* shift new year to March 1 and start months from 1 (not 0),
* it is needed for Gauss' formula
@@ -249,7 +243,7 @@ ngx_http_parse_time(u_char *value, size_t len)
/* Gauss' formula for Grigorian days since March 1, 1 BC */
- return (
+ time = (uint64_t) (
/* days in years including leap years since March 1, 1 BC */
365 * year + year / 4 - year / 100 + year / 400
@@ -268,4 +262,14 @@ ngx_http_parse_time(u_char *value, size_t len)
*/
- 719527 + 31 + 28) * 86400 + hour * 3600 + min * 60 + sec;
+
+#if (NGX_TIME_T_SIZE <= 4)
+
+ if (time > 0x7fffffff) {
+ return NGX_ERROR;
+ }
+
+#endif
+
+ return (time_t) time;
}