]> git.kaiwu.me - nginx.git/commitdiff
refactor ngx_http_arg() using ngx_strcasestrn(),
authorIgor Sysoev <igor@sysoev.ru>
Sat, 4 Apr 2009 17:51:38 +0000 (17:51 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Sat, 4 Apr 2009 17:51:38 +0000 (17:51 +0000)
back out zero termination introduced in r2138

src/http/ngx_http_parse.c
src/http/ngx_http_request.c

index 49f536a857d999c71b1640744f44904cb8da47b1..11e62e6ac42d946b8e842653f4bafa9d010fb0cb 100644 (file)
@@ -1486,20 +1486,20 @@ ngx_http_parse_multi_header_lines(ngx_array_t *headers, ngx_str_t *name,
 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++) {
+
+        /* we need '=' after name, so drop one char from last */
 
-        p = ngx_strcasestrn(p, (char *) name, len - 1);
+        p = ngx_strlcasestrn(p, last - 1, name, len - 1);
 
         if (p == NULL) {
             return NGX_DECLINED;
@@ -1509,7 +1509,7 @@ ngx_http_arg(ngx_http_request_t *r, u_char *name, size_t len, ngx_str_t *value)
 
             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;
index c80ae101c74d5ba80ee5b522fff68b60f42e1ba1..17d867a6307ef746038f8df15603d4fb2049f5d6 100644 (file)
@@ -697,7 +697,6 @@ ngx_http_process_request_line(ngx_event_t *rev)
 
             r->request_line.len = r->request_end - r->request_start;
             r->request_line.data = r->request_start;
-            *r->request_end = '\0';
 
 
             if (r->args_start) {