misc/153748: [libfetch] in ftp_request: closing of the connection
happens too earlier
Aleksey
rndfax at yandex.ru
Thu Jan 6 23:30:06 UTC 2011
>Number: 153748
>Category: misc
>Synopsis: [libfetch] in ftp_request: closing of the connection happens too earlier
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Thu Jan 06 23:30:05 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator: Aleksey
>Release:
>Organization:
>Environment:
FreeBSD r2d2.homenet 8.1-STABLE FreeBSD 8.1-STABLE #7 r215308: Sun Nov 14 21:31:16 UTC 2010 admin at r2d2.homenet:/usr/obj/usr/src/sys/kernel i386
>Description:
libfetch/ftp.c - ftp_request sends command QUIT when it is called only for stat. Therefore, after calling fetchStatURL(..) it's not possible to work with this ftp-cached_connection, because the server closes this connection.
>How-To-Repeat:
#include <sys/param.h>
#include <stdio.h>
#include <fetch.h>
int
main()
{
FILE *ftp;
const char *url = "ftp://ftp2.freebsd.org/pub/FreeBSD/ports/i386/packages-8-stable/UPDATING";
struct url_stat f_stat;
if (fetchStatURL(url, &f_stat, "") == -1) {
printf("fetchStatURL error\n");
return -1;
}
if ((ftp = fetchGetURL(url, "")) == NULL) {
printf("fetchGetURL error\n");
return -1;
}
fclose(ftp);
return 0;
}
this code produces "Broken pipe".
>Fix:
To fix this problem, don't send QUIT in the ftp_request(..), just decrease the count reference to this cached connection. Patch attached.
Patch attached with submission follows:
--- /usr/src/lib/libfetch/ftp.c 2011-01-06 03:00:01.000000000 +0000
+++ /usr/src/lib/libfetch/ftp.c 2011-01-06 03:00:27.000000000 +0000
@@ -1132,7 +1132,7 @@
/* just a stat */
if (strcmp(op, "STAT") == 0) {
- ftp_disconnect(conn);
+ fetch_close(conn);
return (FILE *)1; /* bogus return value */
}
if (strcmp(op, "STOR") == 0 || strcmp(op, "APPE") == 0)
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list