mirror of
https://github.com/nginx/nginx.git
synced 2025-06-07 17:52:38 +08:00
Core: avoid potential underflow in ngx_gmtime().
The underflow may happen for small argument values. Normally the code is optimized by the compiler, which elimitaes the undeflow. Even if the underflow happens, the followup addition will also eliminate it. The change reorders operations to avoid the underflow in any case. Found by Coverity (CID 1605495).
This commit is contained in:
parent
af0978ef69
commit
b857b3415f
@ -360,7 +360,7 @@ ngx_gmtime(time_t t, ngx_tm_t *tp)
|
||||
*/
|
||||
|
||||
/* days since March 1, 1 BC */
|
||||
days = days - (31 + 28) + 719527;
|
||||
days = days + 719527 - (31 + 28);
|
||||
|
||||
/*
|
||||
* The "days" should be adjusted to 1 only, however, some March 1st's go
|
||||
|
Loading…
Reference in New Issue
Block a user