mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Set con->csock to -1 where rbuf_uninitialize was previously used.
This commit is contained in:
parent
c06c8d039f
commit
1b2dce0493
@ -1,3 +1,8 @@
|
|||||||
|
2003-11-26 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
|
* ftp.c: Set con->csock to -1 where rbuf_uninitialize was
|
||||||
|
previously used.
|
||||||
|
|
||||||
2003-11-26 Hrvoje Niksic <hniksic@xemacs.org>
|
2003-11-26 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
* Makefile.in (http$o): Added the trailing backslash that was
|
* Makefile.in (http$o): Added the trailing backslash that was
|
||||||
|
48
src/ftp.c
48
src/ftp.c
@ -290,6 +290,11 @@ getftp (struct url *u, long *len, long restval, ccon *con)
|
|||||||
return (retryable_socket_connect_error (errno)
|
return (retryable_socket_connect_error (errno)
|
||||||
? CONERROR : CONIMPOSSIBLE);
|
? CONERROR : CONIMPOSSIBLE);
|
||||||
|
|
||||||
|
if (cmd & LEAVE_PENDING)
|
||||||
|
con->csock = csock;
|
||||||
|
else
|
||||||
|
con->csock = -1;
|
||||||
|
|
||||||
/* Second: Login with proper USER/PASS sequence. */
|
/* Second: Login with proper USER/PASS sequence. */
|
||||||
logprintf (LOG_VERBOSE, _("Logging in as %s ... "), user);
|
logprintf (LOG_VERBOSE, _("Logging in as %s ... "), user);
|
||||||
if (opt.server_response)
|
if (opt.server_response)
|
||||||
@ -307,12 +312,14 @@ getftp (struct url *u, long *len, long restval, ccon *con)
|
|||||||
logputs (LOG_NOTQUIET, _("\
|
logputs (LOG_NOTQUIET, _("\
|
||||||
Error in server response, closing control connection.\n"));
|
Error in server response, closing control connection.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
return err;
|
return err;
|
||||||
break;
|
break;
|
||||||
case FTPSRVERR:
|
case FTPSRVERR:
|
||||||
logputs (LOG_VERBOSE, "\n");
|
logputs (LOG_VERBOSE, "\n");
|
||||||
logputs (LOG_NOTQUIET, _("Error in server greeting.\n"));
|
logputs (LOG_NOTQUIET, _("Error in server greeting.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
return err;
|
return err;
|
||||||
break;
|
break;
|
||||||
case WRITEFAILED:
|
case WRITEFAILED:
|
||||||
@ -320,18 +327,21 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_NOTQUIET,
|
logputs (LOG_NOTQUIET,
|
||||||
_("Write failed, closing control connection.\n"));
|
_("Write failed, closing control connection.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
return err;
|
return err;
|
||||||
break;
|
break;
|
||||||
case FTPLOGREFUSED:
|
case FTPLOGREFUSED:
|
||||||
logputs (LOG_VERBOSE, "\n");
|
logputs (LOG_VERBOSE, "\n");
|
||||||
logputs (LOG_NOTQUIET, _("The server refuses login.\n"));
|
logputs (LOG_NOTQUIET, _("The server refuses login.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
return FTPLOGREFUSED;
|
return FTPLOGREFUSED;
|
||||||
break;
|
break;
|
||||||
case FTPLOGINC:
|
case FTPLOGINC:
|
||||||
logputs (LOG_VERBOSE, "\n");
|
logputs (LOG_VERBOSE, "\n");
|
||||||
logputs (LOG_NOTQUIET, _("Login incorrect.\n"));
|
logputs (LOG_NOTQUIET, _("Login incorrect.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
return FTPLOGINC;
|
return FTPLOGINC;
|
||||||
break;
|
break;
|
||||||
case FTPOK:
|
case FTPOK:
|
||||||
@ -355,6 +365,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_NOTQUIET, _("\
|
logputs (LOG_NOTQUIET, _("\
|
||||||
Error in server response, closing control connection.\n"));
|
Error in server response, closing control connection.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
return err;
|
return err;
|
||||||
break;
|
break;
|
||||||
case FTPSRVERR:
|
case FTPSRVERR:
|
||||||
@ -376,7 +387,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
|
|
||||||
if (!opt.server_response)
|
if (!opt.server_response)
|
||||||
logprintf (LOG_VERBOSE, "==> PWD ... ");
|
logprintf (LOG_VERBOSE, "==> PWD ... ");
|
||||||
err = ftp_pwd(csock, &con->id);
|
err = ftp_pwd (csock, &con->id);
|
||||||
/* FTPRERR */
|
/* FTPRERR */
|
||||||
switch (err)
|
switch (err)
|
||||||
{
|
{
|
||||||
@ -385,6 +396,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_NOTQUIET, _("\
|
logputs (LOG_NOTQUIET, _("\
|
||||||
Error in server response, closing control connection.\n"));
|
Error in server response, closing control connection.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
return err;
|
return err;
|
||||||
break;
|
break;
|
||||||
case FTPSRVERR :
|
case FTPSRVERR :
|
||||||
@ -438,6 +450,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_NOTQUIET, _("\
|
logputs (LOG_NOTQUIET, _("\
|
||||||
Error in server response, closing control connection.\n"));
|
Error in server response, closing control connection.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
return err;
|
return err;
|
||||||
break;
|
break;
|
||||||
case WRITEFAILED:
|
case WRITEFAILED:
|
||||||
@ -445,6 +458,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_NOTQUIET,
|
logputs (LOG_NOTQUIET,
|
||||||
_("Write failed, closing control connection.\n"));
|
_("Write failed, closing control connection.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
return err;
|
return err;
|
||||||
break;
|
break;
|
||||||
case FTPUNKNOWNTYPE:
|
case FTPUNKNOWNTYPE:
|
||||||
@ -453,6 +467,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
_("Unknown type `%c', closing control connection.\n"),
|
_("Unknown type `%c', closing control connection.\n"),
|
||||||
type_char);
|
type_char);
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
return err;
|
return err;
|
||||||
case FTPOK:
|
case FTPOK:
|
||||||
/* Everything is OK. */
|
/* Everything is OK. */
|
||||||
@ -550,6 +565,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_NOTQUIET, _("\
|
logputs (LOG_NOTQUIET, _("\
|
||||||
Error in server response, closing control connection.\n"));
|
Error in server response, closing control connection.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
return err;
|
return err;
|
||||||
break;
|
break;
|
||||||
case WRITEFAILED:
|
case WRITEFAILED:
|
||||||
@ -557,6 +573,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_NOTQUIET,
|
logputs (LOG_NOTQUIET,
|
||||||
_("Write failed, closing control connection.\n"));
|
_("Write failed, closing control connection.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
return err;
|
return err;
|
||||||
break;
|
break;
|
||||||
case FTPNSFOD:
|
case FTPNSFOD:
|
||||||
@ -564,6 +581,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logprintf (LOG_NOTQUIET, _("No such directory `%s'.\n\n"),
|
logprintf (LOG_NOTQUIET, _("No such directory `%s'.\n\n"),
|
||||||
u->dir);
|
u->dir);
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
return err;
|
return err;
|
||||||
break;
|
break;
|
||||||
case FTPOK:
|
case FTPOK:
|
||||||
@ -588,7 +606,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logprintf (LOG_VERBOSE, "==> SIZE %s ... ", u->file);
|
logprintf (LOG_VERBOSE, "==> SIZE %s ... ", u->file);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ftp_size(csock, u->file, len);
|
err = ftp_size (csock, u->file, len);
|
||||||
/* FTPRERR */
|
/* FTPRERR */
|
||||||
switch (err)
|
switch (err)
|
||||||
{
|
{
|
||||||
@ -598,6 +616,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_NOTQUIET, _("\
|
logputs (LOG_NOTQUIET, _("\
|
||||||
Error in server response, closing control connection.\n"));
|
Error in server response, closing control connection.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
return err;
|
return err;
|
||||||
break;
|
break;
|
||||||
case FTPOK:
|
case FTPOK:
|
||||||
@ -627,6 +646,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_NOTQUIET, _("\
|
logputs (LOG_NOTQUIET, _("\
|
||||||
Error in server response, closing control connection.\n"));
|
Error in server response, closing control connection.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
return err;
|
return err;
|
||||||
break;
|
break;
|
||||||
case WRITEFAILED:
|
case WRITEFAILED:
|
||||||
@ -634,6 +654,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_NOTQUIET,
|
logputs (LOG_NOTQUIET,
|
||||||
_("Write failed, closing control connection.\n"));
|
_("Write failed, closing control connection.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
return err;
|
return err;
|
||||||
break;
|
break;
|
||||||
case FTPNOPASV:
|
case FTPNOPASV:
|
||||||
@ -650,7 +671,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
default:
|
default:
|
||||||
abort ();
|
abort ();
|
||||||
break;
|
break;
|
||||||
} /* switch(err) */
|
} /* switch (err) */
|
||||||
if (err==FTPOK)
|
if (err==FTPOK)
|
||||||
{
|
{
|
||||||
DEBUGP (("trying to connect to %s port %d\n",
|
DEBUGP (("trying to connect to %s port %d\n",
|
||||||
@ -661,7 +682,8 @@ Error in server response, closing control connection.\n"));
|
|||||||
{
|
{
|
||||||
int save_errno = errno;
|
int save_errno = errno;
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
logprintf (LOG_VERBOSE, _("couldn't connect to %s port %hu: %s\n"),
|
con->csock = -1;
|
||||||
|
logprintf (LOG_VERBOSE, _("couldn't connect to %s port %d: %s\n"),
|
||||||
pretty_print_address (&passive_addr), passive_port,
|
pretty_print_address (&passive_addr), passive_port,
|
||||||
strerror (save_errno));
|
strerror (save_errno));
|
||||||
return (retryable_socket_connect_error (save_errno)
|
return (retryable_socket_connect_error (save_errno)
|
||||||
@ -686,6 +708,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_NOTQUIET, _("\
|
logputs (LOG_NOTQUIET, _("\
|
||||||
Error in server response, closing control connection.\n"));
|
Error in server response, closing control connection.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
fd_close (dtsock);
|
fd_close (dtsock);
|
||||||
fd_close (local_sock);
|
fd_close (local_sock);
|
||||||
return err;
|
return err;
|
||||||
@ -695,6 +718,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_NOTQUIET,
|
logputs (LOG_NOTQUIET,
|
||||||
_("Write failed, closing control connection.\n"));
|
_("Write failed, closing control connection.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
fd_close (dtsock);
|
fd_close (dtsock);
|
||||||
fd_close (local_sock);
|
fd_close (local_sock);
|
||||||
return err;
|
return err;
|
||||||
@ -703,6 +727,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_VERBOSE, "\n");
|
logputs (LOG_VERBOSE, "\n");
|
||||||
logprintf (LOG_NOTQUIET, "socket: %s\n", strerror (errno));
|
logprintf (LOG_NOTQUIET, "socket: %s\n", strerror (errno));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
fd_close (dtsock);
|
fd_close (dtsock);
|
||||||
fd_close (local_sock);
|
fd_close (local_sock);
|
||||||
return err;
|
return err;
|
||||||
@ -718,6 +743,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_VERBOSE, "\n");
|
logputs (LOG_VERBOSE, "\n");
|
||||||
logputs (LOG_NOTQUIET, _("Invalid PORT.\n"));
|
logputs (LOG_NOTQUIET, _("Invalid PORT.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
fd_close (dtsock);
|
fd_close (dtsock);
|
||||||
fd_close (local_sock);
|
fd_close (local_sock);
|
||||||
return err;
|
return err;
|
||||||
@ -749,6 +775,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_NOTQUIET, _("\
|
logputs (LOG_NOTQUIET, _("\
|
||||||
Error in server response, closing control connection.\n"));
|
Error in server response, closing control connection.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
fd_close (dtsock);
|
fd_close (dtsock);
|
||||||
fd_close (local_sock);
|
fd_close (local_sock);
|
||||||
return err;
|
return err;
|
||||||
@ -758,6 +785,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_NOTQUIET,
|
logputs (LOG_NOTQUIET,
|
||||||
_("Write failed, closing control connection.\n"));
|
_("Write failed, closing control connection.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
fd_close (dtsock);
|
fd_close (dtsock);
|
||||||
fd_close (local_sock);
|
fd_close (local_sock);
|
||||||
return err;
|
return err;
|
||||||
@ -772,6 +800,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
_("\nREST failed; will not truncate `%s'.\n"),
|
_("\nREST failed; will not truncate `%s'.\n"),
|
||||||
con->target);
|
con->target);
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
fd_close (dtsock);
|
fd_close (dtsock);
|
||||||
fd_close (local_sock);
|
fd_close (local_sock);
|
||||||
return CONTNOTSUPPORTED;
|
return CONTNOTSUPPORTED;
|
||||||
@ -799,6 +828,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
if (opt.spider)
|
if (opt.spider)
|
||||||
{
|
{
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
fd_close (dtsock);
|
fd_close (dtsock);
|
||||||
fd_close (local_sock);
|
fd_close (local_sock);
|
||||||
return RETRFINISHED;
|
return RETRFINISHED;
|
||||||
@ -823,6 +853,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_NOTQUIET, _("\
|
logputs (LOG_NOTQUIET, _("\
|
||||||
Error in server response, closing control connection.\n"));
|
Error in server response, closing control connection.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
fd_close (dtsock);
|
fd_close (dtsock);
|
||||||
fd_close (local_sock);
|
fd_close (local_sock);
|
||||||
return err;
|
return err;
|
||||||
@ -832,6 +863,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_NOTQUIET,
|
logputs (LOG_NOTQUIET,
|
||||||
_("Write failed, closing control connection.\n"));
|
_("Write failed, closing control connection.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
fd_close (dtsock);
|
fd_close (dtsock);
|
||||||
fd_close (local_sock);
|
fd_close (local_sock);
|
||||||
return err;
|
return err;
|
||||||
@ -872,6 +904,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_NOTQUIET, _("\
|
logputs (LOG_NOTQUIET, _("\
|
||||||
Error in server response, closing control connection.\n"));
|
Error in server response, closing control connection.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
fd_close (dtsock);
|
fd_close (dtsock);
|
||||||
fd_close (local_sock);
|
fd_close (local_sock);
|
||||||
return err;
|
return err;
|
||||||
@ -881,6 +914,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_NOTQUIET,
|
logputs (LOG_NOTQUIET,
|
||||||
_("Write failed, closing control connection.\n"));
|
_("Write failed, closing control connection.\n"));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
fd_close (dtsock);
|
fd_close (dtsock);
|
||||||
fd_close (local_sock);
|
fd_close (local_sock);
|
||||||
return err;
|
return err;
|
||||||
@ -945,6 +979,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
{
|
{
|
||||||
logprintf (LOG_NOTQUIET, "%s: %s\n", con->target, strerror (errno));
|
logprintf (LOG_NOTQUIET, "%s: %s\n", con->target, strerror (errno));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
fd_close (dtsock);
|
fd_close (dtsock);
|
||||||
fd_close (local_sock);
|
fd_close (local_sock);
|
||||||
return FOPENERR;
|
return FOPENERR;
|
||||||
@ -1015,6 +1050,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
logprintf (LOG_NOTQUIET, _("%s: %s, closing control connection.\n"),
|
logprintf (LOG_NOTQUIET, _("%s: %s, closing control connection.\n"),
|
||||||
con->target, strerror (errno));
|
con->target, strerror (errno));
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
return FWRITEERR;
|
return FWRITEERR;
|
||||||
}
|
}
|
||||||
else if (res == -1)
|
else if (res == -1)
|
||||||
@ -1040,6 +1076,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
whole file was retrieved nevertheless (but that is for
|
whole file was retrieved nevertheless (but that is for
|
||||||
ftp_loop_internal to decide). */
|
ftp_loop_internal to decide). */
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
return FTPRETRINT;
|
return FTPRETRINT;
|
||||||
} /* err != FTPOK */
|
} /* err != FTPOK */
|
||||||
/* If retrieval failed for any reason, return FTPRETRINT, but do not
|
/* If retrieval failed for any reason, return FTPRETRINT, but do not
|
||||||
@ -1068,6 +1105,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
/* I should probably send 'QUIT' and check for a reply, but this
|
/* I should probably send 'QUIT' and check for a reply, but this
|
||||||
is faster. #### Is it OK, though? */
|
is faster. #### Is it OK, though? */
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
|
con->csock = -1;
|
||||||
}
|
}
|
||||||
/* If it was a listing, and opt.server_response is true,
|
/* If it was a listing, and opt.server_response is true,
|
||||||
print it out. */
|
print it out. */
|
||||||
@ -1677,7 +1715,7 @@ has_insecure_name_p (const char *s)
|
|||||||
if (*s == '/')
|
if (*s == '/')
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (strstr(s, "../") != 0)
|
if (strstr (s, "../") != 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user