sftp client
Corinna Vinschen
vinschen at redhat.com
Tue Feb 6 21:46:16 EST 2001
On Tue, Feb 06, 2001 at 11:21:24AM +0100, Corinna Vinschen wrote:
> > > Trying to GET any files gives me "Couldn't close file: No Such File"
> >
> > Is this after a bad chdir?
>
> No. This also happens immediately:
>
> /src/openssh/bin[2]$ ./sftp localhost
> Connecting to localhost...
> sftp> get x.c
> Couldn't close file: No Such File
>
> However, the file is successfully copied.
Found the reason: in `do_download' and `do_upload', handle and msg are
given up before do_close is called. Patch attached.
Corinna
--
Corinna Vinschen
Cygwin Developer
Red Hat, Inc.
mailto:vinschen at redhat.com
-------------- next part --------------
Index: sftp-client.c
===================================================================
RCS file: /cvs/openssh_cvs/sftp-client.c,v
retrieving revision 1.3
diff -u -p -r1.3 sftp-client.c
--- sftp-client.c 2001/02/05 15:39:22 1.3
+++ sftp-client.c 2001/02/06 10:44:32
@@ -553,6 +553,7 @@ do_download(int fd_in, int fd_out, char
char *handle;
Buffer msg;
Attrib junk, *a;
+ int ret;
a = do_stat(fd_in, fd_out, remote_path);
if (a == NULL)
@@ -672,11 +673,12 @@ do_download(int fd_in, int fd_out, char
offset += len;
xfree(data);
}
- xfree(handle);
- buffer_free(&msg);
close(local_fd);
- return(do_close(fd_in, fd_out, handle, handle_len));
+ ret = do_close(fd_in, fd_out, handle, handle_len);
+ xfree(handle);
+ buffer_free(&msg);
+ return ret;
}
int
@@ -690,6 +692,7 @@ do_upload(int fd_in, int fd_out, char *l
Buffer msg;
struct stat sb;
Attrib a;
+ int ret;
if ((local_fd = open(local_path, O_RDONLY, 0)) == -1) {
error("Couldn't open local file \"%s\" for reading: %s",
@@ -780,8 +783,6 @@ do_upload(int fd_in, int fd_out, char *l
offset += len;
}
- xfree(handle);
- buffer_free(&msg);
if (close(local_fd) == -1) {
error("Couldn't close local file \"%s\": %s", local_path,
@@ -790,5 +791,8 @@ do_upload(int fd_in, int fd_out, char *l
return(-1);
}
- return(do_close(fd_in, fd_out, handle, handle_len));
+ ret = do_close(fd_in, fd_out, handle, handle_len);
+ xfree(handle);
+ buffer_free(&msg);
+ return ret;
}
More information about the openssh-unix-dev
mailing list