]> sjero.net Git - wget/blobdiff - src/ftp-basic.c
[svn] Limit the maximum amount of memory allocated by fd_read_hunk and its
[wget] / src / ftp-basic.c
index 011268b2d58b11ef2f372b7a0f201cc5b0483312..5d32aadc626a5447e368793820940fbe1fd89f0b 100644 (file)
@@ -93,10 +93,11 @@ ftp_response (int fd, char **ret_line)
 static char *
 ftp_request (const char *command, const char *value)
 {
-  char *res = (char *)xmalloc (strlen (command)
-                               + (value ? (1 + strlen (value)) : 0)
-                               + 2 + 1);
-  sprintf (res, "%s%s%s\r\n", command, value ? " " : "", value ? value : "");
+  char *res;
+  if (value)
+    res = concat_strings (command, " ", value, "\r\n", (char *) 0);
+  else
+    res = concat_strings (command, "\r\n", (char *) 0);
   if (opt.server_response)
     {
       /* Hack: don't print out password.  */
@@ -122,10 +123,7 @@ ftp_login (int csock, const char *acc, const char *pass)
   /* Get greeting.  */
   err = ftp_response (csock, &respline);
   if (err != FTPOK)
-    {
-      xfree (respline);
-      return err;
-    }
+    return err;
   if (*respline != '2')
     {
       xfree (respline);