diff src/http/modules/ngx_http_userid_filter_module.c @ 6626:b3682580c1bd

Avoid left-shifting integers into the sign bit, which is undefined. Found with UndefinedBehaviorSanitizer.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 07 Jul 2016 21:02:28 +0300
parents 778ef9c3fd2d
children e6f399a176e7
line wrap: on
line diff
--- a/src/http/modules/ngx_http_userid_filter_module.c
+++ b/src/http/modules/ngx_http_userid_filter_module.c
@@ -836,7 +836,7 @@ ngx_http_userid_init_worker(ngx_cycle_t 
     ngx_gettimeofday(&tp);
 
     /* use the most significant usec part that fits to 16 bits */
-    start_value = ((tp.tv_usec / 20) << 16) | ngx_pid;
+    start_value = (((uint32_t) tp.tv_usec / 20) << 16) | ngx_pid;
 
     return NGX_OK;
 }