]> granicus.if.org Git - curl/commitdiff
ftp: include command in Curl_ftpsend sendbuffer
authorDaniel Gustafsson <daniel@yesql.se>
Thu, 13 Sep 2018 08:10:18 +0000 (10:10 +0200)
committerDaniel Gustafsson <daniel@yesql.se>
Thu, 13 Sep 2018 08:10:18 +0000 (10:10 +0200)
Commit 8238ba9c5f10414a88f502bf3f5d5a42d632984c inadvertently removed
the actual command to be sent from the send buffer in a refactoring.
Add back copying the command into the buffer. Also add more guards
against malformed input while at it.

Closes #2985
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
lib/ftp.c

index 7dbf080045e36bbd93342299b31b379db9234f1a..429708fc560866c24fac186107a590829ad6bc7c 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -3963,10 +3963,14 @@ CURLcode Curl_ftpsend(struct connectdata *conn, const char *cmd)
   enum protection_level data_sec = conn->data_prot;
 #endif
 
+  if(!cmd)
+    return CURLE_BAD_FUNCTION_ARGUMENT;
+
   write_len = strlen(cmd);
-  if(write_len > (sizeof(s) -3))
+  if(!write_len || write_len > (sizeof(s) -3))
     return CURLE_BAD_FUNCTION_ARGUMENT;
 
+  memcpy(&s, cmd, write_len);
   strcpy(&s[write_len], "\r\n"); /* append a trailing CRLF */
   write_len += 2;
   bytes_written = 0;