Mercurial > hg > nginx
changeset 2670:20a655d8a1f8
refactor ngx_http_arg() using ngx_strcasestrn(),
back out zero termination introduced in r2138
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sat, 04 Apr 2009 17:51:38 +0000 |
parents | 5e4d8bd4486c |
children | 627dee566f6c |
files | src/http/ngx_http_parse.c src/http/ngx_http_request.c |
diffstat | 2 files changed, 8 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/http/ngx_http_parse.c Sat Apr 04 17:35:40 2009 +0000 +++ b/src/http/ngx_http_parse.c Sat Apr 04 17:51:38 2009 +0000 @@ -1486,20 +1486,20 @@ ngx_int_t ngx_http_arg(ngx_http_request_t *r, u_char *name, size_t len, ngx_str_t *value) { - u_char *p; + u_char *p, *last; if (r->args.len == 0) { return NGX_DECLINED; } - for (p = r->args.data; *p && *p != ' '; p++) { + p = r->args.data; + last = p + r->args.len; - /* - * although r->args.data is not null-terminated by itself, - * however, there is null in the end of request line - */ + for ( /* void */ ; p < last; p++) { - p = ngx_strcasestrn(p, (char *) name, len - 1); + /* we need '=' after name, so drop one char from last */ + + p = ngx_strlcasestrn(p, last - 1, name, len - 1); if (p == NULL) { return NGX_DECLINED; @@ -1509,7 +1509,7 @@ value->data = p + len + 1; - p = (u_char *) ngx_strchr(p, '&'); + p = ngx_strlchr(p, last, '&'); if (p == NULL) { p = r->args.data + r->args.len;