summaryrefslogtreecommitdiffstats
path: root/lib/libfetch
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2009-11-25 14:57:07 +0000
committerattilio <attilio@FreeBSD.org>2009-11-25 14:57:07 +0000
commit6b1883b1f0036c5d67df93e1084064b447e84c6f (patch)
tree7cc5a061d9d7debf82a25a0bb73c1d7cd9cc76ee /lib/libfetch
parentd4d8d346dc96f945ec89b678fa0951725ca88c42 (diff)
downloadFreeBSD-src-6b1883b1f0036c5d67df93e1084064b447e84c6f.zip
FreeBSD-src-6b1883b1f0036c5d67df93e1084064b447e84c6f.tar.gz
Fix a socket leak in ftp_request() after that a connection is established.
Submitted by: Sandvine Incorporated Reviewed by: des, emaste Sponsored by: Sandvine Incorporated MFC: 1 week
Diffstat (limited to 'lib/libfetch')
-rw-r--r--lib/libfetch/ftp.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c
index d0d597f..a0ba510 100644
--- a/lib/libfetch/ftp.c
+++ b/lib/libfetch/ftp.c
@@ -1122,17 +1122,19 @@ ftp_request(struct url *url, const char *op, struct url_stat *us,
/* change directory */
if (ftp_cwd(conn, url->doc) == -1)
- return (NULL);
+ goto errsock;
/* stat file */
if (us && ftp_stat(conn, url->doc, us) == -1
&& fetchLastErrCode != FETCH_PROTO
&& fetchLastErrCode != FETCH_UNAVAIL)
- return (NULL);
+ goto errsock;
/* just a stat */
- if (strcmp(op, "STAT") == 0)
+ if (strcmp(op, "STAT") == 0) {
+ ftp_disconnect(conn);
return (FILE *)1; /* bogus return value */
+ }
if (strcmp(op, "STOR") == 0 || strcmp(op, "APPE") == 0)
oflag = O_WRONLY;
else
@@ -1140,6 +1142,10 @@ ftp_request(struct url *url, const char *op, struct url_stat *us,
/* initiate the transfer */
return (ftp_transfer(conn, op, url->doc, oflag, url->offset, flags));
+
+errsock:
+ ftp_disconnect(conn);
+ return (NULL);
}
/*
OpenPOWER on IntegriCloud