comparison src/http/ngx_http.c @ 8121:4eb1383f6432

Fixed handling of very long locations (ticket #2435). Previously, location prefix length in ngx_http_location_tree_node_t was stored as "u_char", and therefore location prefixes longer than 255 bytes were handled incorrectly. Fix is to use "u_short" instead. With "u_short", prefixes up to 65535 bytes can be safely used, and this isn't reachable due to NGX_CONF_BUFFER, which is 4096 bytes.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 26 Jan 2023 03:34:44 +0300
parents 61abb35bb8cf
children 106328a70f4e
comparison
equal deleted inserted replaced
8120:c7e103acb409 8121:4eb1383f6432
1128 node->inclusive = lq->inclusive; 1128 node->inclusive = lq->inclusive;
1129 1129
1130 node->auto_redirect = (u_char) ((lq->exact && lq->exact->auto_redirect) 1130 node->auto_redirect = (u_char) ((lq->exact && lq->exact->auto_redirect)
1131 || (lq->inclusive && lq->inclusive->auto_redirect)); 1131 || (lq->inclusive && lq->inclusive->auto_redirect));
1132 1132
1133 node->len = (u_char) len; 1133 node->len = (u_short) len;
1134 ngx_memcpy(node->name, &lq->name->data[prefix], len); 1134 ngx_memcpy(node->name, &lq->name->data[prefix], len);
1135 1135
1136 ngx_queue_split(locations, q, &tail); 1136 ngx_queue_split(locations, q, &tail);
1137 1137
1138 if (ngx_queue_empty(locations)) { 1138 if (ngx_queue_empty(locations)) {