[MPlayer-dev-eng] [PATCH 4/7] stream ftp: Only send QUIT command if connected
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Mon Nov 12 20:38:53 CET 2012
On Sun, Nov 11, 2012 at 10:01:22PM +0100, Alexander Strasser wrote:
> Do not attempt to send commands without control connections.
>
> Signed-off-by: Alexander Strasser <eclipse7 at gmx.net>
> ---
> stream/stream_ftp.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/stream/stream_ftp.c b/stream/stream_ftp.c
> index a24117c..e136da8 100644
> --- a/stream/stream_ftp.c
> +++ b/stream/stream_ftp.c
> @@ -401,9 +401,11 @@ static void close_f(stream_t *s) {
> s->fd = 0;
> }
>
> - FtpSendCmd("QUIT",p,NULL);
> + if (p->handle) {
> + FtpSendCmd("QUIT", p, NULL);
> + closesocket(p->handle);
> + }
"handle" seems to be a descriptor, the comparison against 0
makes no sense then.
It needs to be initialized to -1, and the check must be against
!= -1 or >= 0 (probably can't use -1, because some functions return
TCP_ERROR_FATAL which is -2).
Same applies to e.g. s->fd = 0; and similar in line 337, 373 and
375.
This probably has some real bugs, since some places actually
check for s->fd >= 0 (though it might be that it was me who
changed those just recently).
More information about the MPlayer-dev-eng
mailing list