]> granicus.if.org Git - curl/commitdiff
http: clarify header buffer size calculation
authorDaniel Gustafsson <daniel@yesql.se>
Mon, 24 Jun 2019 21:30:31 +0000 (23:30 +0200)
committerDaniel Gustafsson <daniel@yesql.se>
Mon, 24 Jun 2019 21:35:06 +0000 (23:35 +0200)
The header buffer size calculation can from static analysis seem to
overlow as it performs an addition between two size_t variables and
stores the result in a size_t variable. Overflow is however guarded
against elsewhere since the input to the addition is regulated by
the maximum read buffer size. Clarify this with a comment since the
question was asked.

Reviewed-by: Daniel Stenberg <daniel@haxx.se>
lib/http.c

index d01e1bfdbb8e3ebb0d56d7407230dc3007a14148..14d1e89ebc76b4f14267568b3a9b20b5e51e3b35 100644 (file)
@@ -3147,6 +3147,9 @@ static CURLcode header_append(struct Curl_easy *data,
                               struct SingleRequest *k,
                               size_t length)
 {
+  /* length is at most the size of a full read buffer, for which the upper
+     bound is CURL_MAX_READ_SIZE. There is thus no chance of overflow in this
+     calculation. */
   size_t newsize = k->hbuflen + length;
   if(newsize > CURL_MAX_HTTP_HEADER) {
     /* The reason to have a max limit for this is to avoid the risk of a bad