Mercurial > hg > nginx
comparison 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 |
comparison
equal
deleted
inserted
replaced
6625:a616bdc38645 | 6626:b3682580c1bd |
---|---|
998 /* find the number of the characters to be escaped */ | 998 /* find the number of the characters to be escaped */ |
999 | 999 |
1000 n = 0; | 1000 n = 0; |
1001 | 1001 |
1002 while (size) { | 1002 while (size) { |
1003 if (escape[*src >> 5] & (1 << (*src & 0x1f))) { | 1003 if (escape[*src >> 5] & (1U << (*src & 0x1f))) { |
1004 n++; | 1004 n++; |
1005 } | 1005 } |
1006 src++; | 1006 src++; |
1007 size--; | 1007 size--; |
1008 } | 1008 } |
1009 | 1009 |
1010 return (uintptr_t) n; | 1010 return (uintptr_t) n; |
1011 } | 1011 } |
1012 | 1012 |
1013 while (size) { | 1013 while (size) { |
1014 if (escape[*src >> 5] & (1 << (*src & 0x1f))) { | 1014 if (escape[*src >> 5] & (1U << (*src & 0x1f))) { |
1015 *dst++ = '\\'; | 1015 *dst++ = '\\'; |
1016 *dst++ = 'x'; | 1016 *dst++ = 'x'; |
1017 *dst++ = hex[*src >> 4]; | 1017 *dst++ = hex[*src >> 4]; |
1018 *dst++ = hex[*src & 0xf]; | 1018 *dst++ = hex[*src & 0xf]; |
1019 src++; | 1019 src++; |