From 90e7f8b1110c44d88962644a60e4910b684125de Mon Sep 17 00:00:00 2001 From: joerg Date: Fri, 20 Aug 2010 17:56:49 +0000 Subject: libfetch-2.33: Don't leak FTP connections on errors in fetch or if only stat is requested. Reported via Xavier Chantry. --- net/libfetch/Makefile | 4 ++-- net/libfetch/files/ftp.c | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/net/libfetch/Makefile b/net/libfetch/Makefile index daadd8c9fad..4f2c04e7297 100644 --- a/net/libfetch/Makefile +++ b/net/libfetch/Makefile @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.39 2010/06/13 21:38:08 joerg Exp $ +# $NetBSD: Makefile,v 1.40 2010/08/20 17:56:49 joerg Exp $ # -DISTNAME= libfetch-2.32 +DISTNAME= libfetch-2.33 CATEGORIES= net MASTER_SITES= # empty DISTFILES= # empty diff --git a/net/libfetch/files/ftp.c b/net/libfetch/files/ftp.c index 9ef5ac939d4..cd6bee13f40 100644 --- a/net/libfetch/files/ftp.c +++ b/net/libfetch/files/ftp.c @@ -1,4 +1,4 @@ -/* $NetBSD: ftp.c,v 1.35 2010/03/21 16:48:43 joerg Exp $ */ +/* $NetBSD: ftp.c,v 1.36 2010/08/20 17:56:49 joerg Exp $ */ /*- * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav * Copyright (c) 2008, 2009, 2010 Joerg Sonnenberger @@ -1155,12 +1155,14 @@ ftp_request(struct url *url, const char *op, const char *op_arg, return (NULL); if ((path = fetchUnquotePath(url)) == NULL) { + fetch_close(conn); fetch_syserr(); return NULL; } /* change directory */ if (ftp_cwd(conn, path, op_arg != NULL) == -1) { + fetch_close(conn); free(path); return (NULL); } @@ -1173,12 +1175,14 @@ ftp_request(struct url *url, const char *op, const char *op_arg, if (us && ftp_stat(conn, path, us) == -1 && fetchLastErrCode != FETCH_PROTO && fetchLastErrCode != FETCH_UNAVAIL) { + fetch_close(conn); free(path); return (NULL); } if (if_modified_since && url->last_modified > 0 && url->last_modified >= us->mtime) { + fetch_cache_put(conn, ftp_disconnect); free(path); fetchLastErrCode = FETCH_UNCHANGED; snprintf(fetchLastErrString, MAXERRSTRING, "Unchanged"); @@ -1187,6 +1191,7 @@ ftp_request(struct url *url, const char *op, const char *op_arg, /* just a stat */ if (strcmp(op, "STAT") == 0) { + fetch_cache_put(conn, ftp_disconnect); free(path); return fetchIO_unopen(NULL, NULL, NULL, NULL); } -- cgit v1.2.3