diff src/http/modules/ngx_http_log_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 ac2a8e4d8f01
children 0cf4e82e7c48
line wrap: on
line diff
--- a/src/http/modules/ngx_http_log_module.c
+++ b/src/http/modules/ngx_http_log_module.c
@@ -1000,7 +1000,7 @@ ngx_http_log_escape(u_char *dst, u_char 
         n = 0;
 
         while (size) {
-            if (escape[*src >> 5] & (1 << (*src & 0x1f))) {
+            if (escape[*src >> 5] & (1U << (*src & 0x1f))) {
                 n++;
             }
             src++;
@@ -1011,7 +1011,7 @@ ngx_http_log_escape(u_char *dst, u_char 
     }
 
     while (size) {
-        if (escape[*src >> 5] & (1 << (*src & 0x1f))) {
+        if (escape[*src >> 5] & (1U << (*src & 0x1f))) {
             *dst++ = '\\';
             *dst++ = 'x';
             *dst++ = hex[*src >> 4];