From 44a2b97bd2773dc679ebce32eaf3c6f4f665f36c Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Tue, 17 Mar 2015 00:24:34 +0300 Subject: [PATCH] Core: expose maximum values of time_t and ngx_int_t. These are needed to detect overflows. --- auto/unix | 1 + src/core/ngx_config.h | 3 +++ src/os/win32/ngx_win32_config.h | 1 + 3 files changed, 5 insertions(+) diff --git a/auto/unix b/auto/unix index 10fd3d293..dfeb84832 100755 --- a/auto/unix +++ b/auto/unix @@ -489,6 +489,7 @@ ngx_param=NGX_OFF_T_LEN; ngx_value=$ngx_max_len; . auto/types/value ngx_type="time_t"; . auto/types/sizeof ngx_param=NGX_TIME_T_SIZE; ngx_value=$ngx_size; . auto/types/value ngx_param=NGX_TIME_T_LEN; ngx_value=$ngx_max_len; . auto/types/value +ngx_param=NGX_MAX_TIME_T_VALUE; ngx_value=$ngx_max_value; . auto/types/value # syscalls, libc calls and some features diff --git a/src/core/ngx_config.h b/src/core/ngx_config.h index 1da71f8d1..145e43a44 100644 --- a/src/core/ngx_config.h +++ b/src/core/ngx_config.h @@ -85,8 +85,11 @@ typedef intptr_t ngx_flag_t; #if (NGX_PTR_SIZE == 4) #define NGX_INT_T_LEN NGX_INT32_LEN +#define NGX_MAX_INT_T_VALUE 2147483647 + #else #define NGX_INT_T_LEN NGX_INT64_LEN +#define NGX_MAX_INT_T_VALUE 9223372036854775807 #endif diff --git a/src/os/win32/ngx_win32_config.h b/src/os/win32/ngx_win32_config.h index fcbb30845..89312ba55 100644 --- a/src/os/win32/ngx_win32_config.h +++ b/src/os/win32/ngx_win32_config.h @@ -175,6 +175,7 @@ typedef int sig_atomic_t; #define NGX_MAX_SIZE_T_VALUE 2147483647 #define NGX_TIME_T_LEN (sizeof("-2147483648") - 1) #define NGX_TIME_T_SIZE 4 +#define NGX_MAX_TIME_T_VALUE 2147483647 #define NGX_OFF_T_LEN (sizeof("-9223372036854775807") - 1) #define NGX_MAX_OFF_T_VALUE 9223372036854775807 #define NGX_SIG_ATOMIC_T_SIZE 4