]> granicus.if.org Git - libevent/commitdiff
http: cleanup of the request-line parsing
authorAzat Khuzhin <a3at.mail@gmail.com>
Mon, 22 Oct 2018 20:25:01 +0000 (23:25 +0300)
committerAzat Khuzhin <a3at.mail@gmail.com>
Mon, 22 Oct 2018 20:55:35 +0000 (23:55 +0300)
http.c

diff --git a/http.c b/http.c
index 7db4d7827235adb9224ebd55f07724783e825648..b6bbc6999aed392df72baf1204187afe14f1671d 100644 (file)
--- a/http.c
+++ b/http.c
@@ -1825,11 +1825,11 @@ evhttp_parse_request_line(struct evhttp_request *req, char *line)
        req->type = type;
 
        if (evhttp_parse_http_version(version, req) < 0)
-               return (-1);
+               return -1;
 
        if ((req->uri = mm_strdup(uri)) == NULL) {
                event_debug(("%s: mm_strdup", __func__));
-               return (-1);
+               return -1;
        }
 
        if (type == EVHTTP_REQ_CONNECT) {
@@ -1854,7 +1854,7 @@ evhttp_parse_request_line(struct evhttp_request *req, char *line)
            !evhttp_find_vhost(req->evcon->http_server, NULL, hostname))
                req->flags |= EVHTTP_PROXY_REQUEST;
 
-       return (0);
+       return 0;
 }
 
 const char *
@@ -1989,9 +1989,9 @@ evhttp_parse_firstline_(struct evhttp_request *req, struct evbuffer *buffer)
        char *line;
        enum message_read_status status = ALL_DATA_READ;
 
-       size_t line_length;
+       size_t len;
        /* XXX try */
-       line = evbuffer_readln(buffer, &line_length, EVBUFFER_EOL_CRLF);
+       line = evbuffer_readln(buffer, &len, EVBUFFER_EOL_CRLF);
        if (line == NULL) {
                if (req->evcon != NULL &&
                    evbuffer_get_length(buffer) > req->evcon->max_headers_size)
@@ -2000,13 +2000,12 @@ evhttp_parse_firstline_(struct evhttp_request *req, struct evbuffer *buffer)
                        return (MORE_DATA_EXPECTED);
        }
 
-       if (req->evcon != NULL &&
-           line_length > req->evcon->max_headers_size) {
+       if (req->evcon != NULL && len > req->evcon->max_headers_size) {
                mm_free(line);
                return (DATA_TOO_LONG);
        }
 
-       req->headers_size = line_length;
+       req->headers_size = len;
 
        switch (req->kind) {
        case EVHTTP_REQUEST:
@@ -2063,12 +2062,12 @@ evhttp_parse_headers_(struct evhttp_request *req, struct evbuffer* buffer)
        enum message_read_status status = MORE_DATA_EXPECTED;
 
        struct evkeyvalq* headers = req->input_headers;
-       size_t line_length;
-       while ((line = evbuffer_readln(buffer, &line_length, EVBUFFER_EOL_CRLF))
+       size_t len;
+       while ((line = evbuffer_readln(buffer, &len, EVBUFFER_EOL_CRLF))
               != NULL) {
                char *skey, *svalue;
 
-               req->headers_size += line_length;
+               req->headers_size += len;
 
                if (req->evcon != NULL &&
                    req->headers_size > req->evcon->max_headers_size) {