]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: Minor change to make sure http_response_header.size is always correct.
authorTimo Sirainen <tss@iki.fi>
Thu, 11 Jul 2013 07:25:32 +0000 (10:25 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 11 Jul 2013 07:25:32 +0000 (10:25 +0300)
The current http-header-parser already guaranteed that it is, but this
change just adds extra guarantees that it won't break in future. Besides,
this change improves the performance slightly by avoiding strlen().

src/lib-http/http-response-parser.c

index 76fdb70ef5047c9a58e4be2d905cdbebc3626f9d..2eea86a9341f376780cd260d20ca4b3cae27a441 100644 (file)
@@ -267,10 +267,12 @@ http_response_parse_header(struct http_response_parser *parser,
 {
        struct http_response_header *hdr;
        struct http_parser hparser;
+       void *value;
 
        hdr = array_append_space(&parser->response->headers);
        hdr->key = p_strdup(parser->response_pool, name);
-       hdr->value = p_strndup(parser->response_pool, data, size);
+       hdr->value = value = p_malloc(parser->response_pool, size+1);
+       memcpy(value, data, size);
        hdr->size = size;
 
        switch (name[0]) {