]> sjero.net Git - wget/blobdiff - src/ftp.c
[svn] Commit my url.c fix (space as unsafe character) and Jan's
[wget] / src / ftp.c
index a8b79075678d8beb5b0b30fdf1b9e52fa10078b5..8ce71fd66b89bdf340d882ce118afc4abbba6d68 100644 (file)
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -57,9 +57,11 @@ extern int h_errno;
 
 extern char ftp_last_respline[];
 
+/* #### Global variables??  These two should be members of struct
+   ccon!  */
+
 static enum stype host_type=ST_UNIX;
 static char *pwd;
-static int  pwd_len;
 
 /* Look for regexp "( *[0-9]+ *byte" (literal parenthesis) anywhere in
    the string S, and return the number converted to long, if found, 0
@@ -133,7 +135,7 @@ getftp (const struct urlinfo *u, long *len, long restval, ccon *con)
   search_netrc (u->host, (const char **)&user, (const char **)&passwd, 1);
   user = user ? user : opt.ftp_acc;
   if (!opt.ftp_pass)
-    opt.ftp_pass = xstrdup (ftp_getaddress ());
+    opt.ftp_pass = ftp_getaddress ();
   passwd = passwd ? passwd : opt.ftp_pass;
   assert (user && passwd);
 
@@ -279,7 +281,6 @@ Error in server response, closing control connection.\n"));
       if (!opt.server_response)
        logprintf (LOG_VERBOSE, "==> PWD ... ");
       err = ftp_pwd(&con->rbuf, &pwd);
-      pwd_len = strlen(pwd);
       /* FTPRERR */
       switch (err)
       {
@@ -352,8 +353,10 @@ Error in server response, closing control connection.\n"));
          /* Change working directory. If the FTP host runs VMS and
              the path specified is absolute, we will have to convert
              it to VMS style as VMS does not like leading slashes */
+         DEBUGP (("changing working directory\n"));
          if (*(u->dir) == '/')
            {
+             int pwd_len = strlen (pwd);
              char *result = (char *)alloca (strlen (u->dir) + pwd_len + 10);
              *result = '\0';
              switch (host_type)
@@ -373,6 +376,7 @@ Error in server response, closing control connection.\n"));
                  }
                  break;
                case ST_UNIX:
+               case ST_WINNT:
                  /* pwd_len == 1 means pwd = "/", but u->dir begins with '/'
                     already */
                  if (pwd_len > 1)
@@ -1283,7 +1287,7 @@ ftp_retrieve_list (struct urlinfo *u, struct fileinfo *f, ccon *con)
              if (local_size == f->size && tml >= f->tstamp)
                {
                  logprintf (LOG_VERBOSE, _("\
-Server file not newer than local file `%s' -- not retrieving.\n\n"), u->local);
+Server file no newer than local file `%s' -- not retrieving.\n\n"), u->local);
                  dlthis = 0;
                }
              else if (local_size != f->size)
@@ -1634,6 +1638,8 @@ ftp_loop (struct urlinfo *u, int *dt)
   /* If a connection was left, quench it.  */
   if (rbuf_initialized_p (&con.rbuf))
     CLOSE (RBUF_FD (&con.rbuf));
+  FREE_MAYBE (pwd);
+  pwd = NULL;
   return res;
 }