]> granicus.if.org Git - curl/commitdiff
transfer: init the infilesize from the postfields...
authorDaniel Stenberg <daniel@haxx.se>
Mon, 29 May 2017 22:45:54 +0000 (00:45 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 30 May 2017 09:39:42 +0000 (11:39 +0200)
... with a strlen() if no size was set, and do this in the pretransfer
function so that the info is set early. Otherwise, the default strlen()
done on the POSTFIELDS data never sets state.infilesize.

Reported-by: Vincas Razma
Bug: #1294

lib/http.c
lib/transfer.c

index 8e7fb0fa98b967b3fd8257f723eff04bae5b5c98..21574e21d7a11634fa2dfb52b8e4fc7b01ad2e27 100644 (file)
@@ -419,8 +419,6 @@ static CURLcode http_perhapsrewind(struct connectdata *conn)
     case HTTPREQ_POST:
       if(data->state.infilesize != -1)
         expectsend = data->state.infilesize;
-      else if(data->set.postfields)
-        expectsend = (curl_off_t)strlen(data->set.postfields);
       break;
     case HTTPREQ_PUT:
       if(data->state.infilesize != -1)
@@ -2559,12 +2557,9 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
 
     if(conn->bits.authneg)
       postsize = 0;
-    else {
-      /* figure out the size of the postfields */
-      postsize = (data->state.infilesize != -1)?
-        data->state.infilesize:
-        (data->set.postfields? (curl_off_t)strlen(data->set.postfields):-1);
-    }
+    else
+      /* the size of the post body */
+      postsize = data->state.infilesize;
 
     /* We only set Content-Length and allow a custom Content-Length if
        we don't upload data chunked, as RFC2616 forbids us to set both
index 799fd4da8ae344a85be96468dd7ec479fa077d73..43e8f64aa89d246856d2c015c020f799c22b6451 100644 (file)
@@ -1309,8 +1309,11 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
 
   if(data->set.httpreq == HTTPREQ_PUT)
     data->state.infilesize = data->set.filesize;
-  else
+  else {
     data->state.infilesize = data->set.postfieldsize;
+    if(data->set.postfields && (data->state.infilesize == -1))
+      data->state.infilesize = (curl_off_t)strlen(data->set.postfields);
+  }
 
   /* If there is a list of cookie files to read, do it now! */
   if(data->change.cookielist)