Mercurial > hg > nginx
comparison src/http/ngx_http_parse.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 | 302ff40c9bc9 |
children | 57148b755320 |
comparison
equal
deleted
inserted
replaced
6625:a616bdc38645 | 6626:b3682580c1bd |
---|---|
479 | 479 |
480 | 480 |
481 /* check "/.", "//", "%", and "\" (Win32) in URI */ | 481 /* check "/.", "//", "%", and "\" (Win32) in URI */ |
482 case sw_after_slash_in_uri: | 482 case sw_after_slash_in_uri: |
483 | 483 |
484 if (usual[ch >> 5] & (1 << (ch & 0x1f))) { | 484 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
485 state = sw_check_uri; | 485 state = sw_check_uri; |
486 break; | 486 break; |
487 } | 487 } |
488 | 488 |
489 switch (ch) { | 489 switch (ch) { |
538 break; | 538 break; |
539 | 539 |
540 /* check "/", "%" and "\" (Win32) in URI */ | 540 /* check "/", "%" and "\" (Win32) in URI */ |
541 case sw_check_uri: | 541 case sw_check_uri: |
542 | 542 |
543 if (usual[ch >> 5] & (1 << (ch & 0x1f))) { | 543 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
544 break; | 544 break; |
545 } | 545 } |
546 | 546 |
547 switch (ch) { | 547 switch (ch) { |
548 case '/': | 548 case '/': |
624 | 624 |
625 | 625 |
626 /* URI */ | 626 /* URI */ |
627 case sw_uri: | 627 case sw_uri: |
628 | 628 |
629 if (usual[ch >> 5] & (1 << (ch & 0x1f))) { | 629 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
630 break; | 630 break; |
631 } | 631 } |
632 | 632 |
633 switch (ch) { | 633 switch (ch) { |
634 case ' ': | 634 case ' ': |
1129 break; | 1129 break; |
1130 | 1130 |
1131 /* check "/.", "//", "%", and "\" (Win32) in URI */ | 1131 /* check "/.", "//", "%", and "\" (Win32) in URI */ |
1132 case sw_after_slash_in_uri: | 1132 case sw_after_slash_in_uri: |
1133 | 1133 |
1134 if (usual[ch >> 5] & (1 << (ch & 0x1f))) { | 1134 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
1135 state = sw_check_uri; | 1135 state = sw_check_uri; |
1136 break; | 1136 break; |
1137 } | 1137 } |
1138 | 1138 |
1139 switch (ch) { | 1139 switch (ch) { |
1177 break; | 1177 break; |
1178 | 1178 |
1179 /* check "/", "%" and "\" (Win32) in URI */ | 1179 /* check "/", "%" and "\" (Win32) in URI */ |
1180 case sw_check_uri: | 1180 case sw_check_uri: |
1181 | 1181 |
1182 if (usual[ch >> 5] & (1 << (ch & 0x1f))) { | 1182 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
1183 break; | 1183 break; |
1184 } | 1184 } |
1185 | 1185 |
1186 switch (ch) { | 1186 switch (ch) { |
1187 case '/': | 1187 case '/': |
1226 break; | 1226 break; |
1227 | 1227 |
1228 /* URI */ | 1228 /* URI */ |
1229 case sw_uri: | 1229 case sw_uri: |
1230 | 1230 |
1231 if (usual[ch >> 5] & (1 << (ch & 0x1f))) { | 1231 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
1232 break; | 1232 break; |
1233 } | 1233 } |
1234 | 1234 |
1235 switch (ch) { | 1235 switch (ch) { |
1236 case ' ': | 1236 case ' ': |
1287 | 1287 |
1288 switch (state) { | 1288 switch (state) { |
1289 | 1289 |
1290 case sw_usual: | 1290 case sw_usual: |
1291 | 1291 |
1292 if (usual[ch >> 5] & (1 << (ch & 0x1f))) { | 1292 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
1293 *u++ = ch; | 1293 *u++ = ch; |
1294 ch = *p++; | 1294 ch = *p++; |
1295 break; | 1295 break; |
1296 } | 1296 } |
1297 | 1297 |
1356 ch = *p++; | 1356 ch = *p++; |
1357 break; | 1357 break; |
1358 | 1358 |
1359 case sw_slash: | 1359 case sw_slash: |
1360 | 1360 |
1361 if (usual[ch >> 5] & (1 << (ch & 0x1f))) { | 1361 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
1362 state = sw_usual; | 1362 state = sw_usual; |
1363 *u++ = ch; | 1363 *u++ = ch; |
1364 ch = *p++; | 1364 ch = *p++; |
1365 break; | 1365 break; |
1366 } | 1366 } |
1399 ch = *p++; | 1399 ch = *p++; |
1400 break; | 1400 break; |
1401 | 1401 |
1402 case sw_dot: | 1402 case sw_dot: |
1403 | 1403 |
1404 if (usual[ch >> 5] & (1 << (ch & 0x1f))) { | 1404 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
1405 state = sw_usual; | 1405 state = sw_usual; |
1406 *u++ = ch; | 1406 *u++ = ch; |
1407 ch = *p++; | 1407 ch = *p++; |
1408 break; | 1408 break; |
1409 } | 1409 } |
1440 ch = *p++; | 1440 ch = *p++; |
1441 break; | 1441 break; |
1442 | 1442 |
1443 case sw_dot_dot: | 1443 case sw_dot_dot: |
1444 | 1444 |
1445 if (usual[ch >> 5] & (1 << (ch & 0x1f))) { | 1445 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
1446 state = sw_usual; | 1446 state = sw_usual; |
1447 *u++ = ch; | 1447 *u++ = ch; |
1448 ch = *p++; | 1448 ch = *p++; |
1449 break; | 1449 break; |
1450 } | 1450 } |
1834 if (ch == '%') { | 1834 if (ch == '%') { |
1835 quoted = 1; | 1835 quoted = 1; |
1836 continue; | 1836 continue; |
1837 } | 1837 } |
1838 | 1838 |
1839 if (usual[ch >> 5] & (1 << (ch & 0x1f))) { | 1839 if (usual[ch >> 5] & (1U << (ch & 0x1f))) { |
1840 continue; | 1840 continue; |
1841 } | 1841 } |
1842 | 1842 |
1843 if (ch == '?') { | 1843 if (ch == '?') { |
1844 args->len = len - 1; | 1844 args->len = len - 1; |