diff options
author | Valentin Bartenev <vbart@nginx.com> | 2017-07-17 17:23:51 +0300 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2017-07-17 17:23:51 +0300 |
commit | 9197a3c8741a8832e6f6ed24a72dc5b078d840fd (patch) | |
tree | 43e64c8410806c986a6b331cf4bba4b9898b5c86 /src/core/ngx_string.c | |
parent | 7b06d9c326f3e24a9d1402a5d3d4b539febdf64b (diff) | |
download | nginx-9197a3c8741a8832e6f6ed24a72dc5b078d840fd.tar.gz nginx-9197a3c8741a8832e6f6ed24a72dc5b078d840fd.zip |
Parenthesized ASCII-related calculations.
This also fixes potential undefined behaviour in the range and slice filter
modules, caused by local overflows of signed integers in expressions.
Diffstat (limited to 'src/core/ngx_string.c')
-rw-r--r-- | src/core/ngx_string.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/core/ngx_string.c b/src/core/ngx_string.c index 7526f60d2..de10a064d 100644 --- a/src/core/ngx_string.c +++ b/src/core/ngx_string.c @@ -178,7 +178,7 @@ ngx_vslprintf(u_char *buf, u_char *last, const char *fmt, va_list args) slen = (size_t) -1; while (*fmt >= '0' && *fmt <= '9') { - width = width * 10 + *fmt++ - '0'; + width = width * 10 + (*fmt++ - '0'); } @@ -211,7 +211,7 @@ ngx_vslprintf(u_char *buf, u_char *last, const char *fmt, va_list args) fmt++; while (*fmt >= '0' && *fmt <= '9') { - frac_width = frac_width * 10 + *fmt++ - '0'; + frac_width = frac_width * 10 + (*fmt++ - '0'); } break; @@ -1655,7 +1655,7 @@ ngx_unescape_uri(u_char **dst, u_char **src, size_t size, ngx_uint_t type) state = sw_usual; if (ch >= '0' && ch <= '9') { - ch = (u_char) ((decoded << 4) + ch - '0'); + ch = (u_char) ((decoded << 4) + (ch - '0')); if (type & NGX_UNESCAPE_REDIRECT) { if (ch > '%' && ch < 0x7f) { @@ -1675,7 +1675,7 @@ ngx_unescape_uri(u_char **dst, u_char **src, size_t size, ngx_uint_t type) c = (u_char) (ch | 0x20); if (c >= 'a' && c <= 'f') { - ch = (u_char) ((decoded << 4) + c - 'a' + 10); + ch = (u_char) ((decoded << 4) + (c - 'a') + 10); if (type & NGX_UNESCAPE_URI) { if (ch == '?') { |