summaryrefslogtreecommitdiff
path: root/noncore/net/ftplib/ftplib.c
Side-by-side diff
Diffstat (limited to 'noncore/net/ftplib/ftplib.c') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/ftplib/ftplib.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/noncore/net/ftplib/ftplib.c b/noncore/net/ftplib/ftplib.c
index efcd6f0..addf9d2 100644
--- a/noncore/net/ftplib/ftplib.c
+++ b/noncore/net/ftplib/ftplib.c
@@ -1163,25 +1163,29 @@ static int FtpXfer(const char *localfile, const char *path,
ac[1] = 'b';
local = fopen(localfile, ac);
if (local == NULL)
{
strncpy(nControl->response, strerror(errno),
sizeof(nControl->response));
return 0;
}
}
if (local == NULL)
local = (typ == FTPLIB_FILE_WRITE) ? stdin : stdout;
if (!FtpAccess(path, typ, mode, nControl, &nData))
+ {
+ if (localfile != NULL)
+ fclose(local);
return 0;
+ }
dbuf = malloc(FTPLIB_BUFSIZ);
if (typ == FTPLIB_FILE_WRITE)
{
while ((l = fread(dbuf, 1, FTPLIB_BUFSIZ, local)) > 0)
if ((c = FtpWrite(dbuf, l, nData)) < l)
{
printf("short write: passed %d, wrote %d\n", l, c);
rv = 0;
break;
}
}
else