mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 01:02:24 +00:00
Fix sftp_put_file returning success on failed transfers.
Due to a shadowed variable, transfer failures were not reflected in the return code to sftp_put_file. Instead of tracking the return code, use the 'err' variable to decide which return code to use.
This commit is contained in:
parent
57e21d756e
commit
e9a76883ad
10
psftp.c
10
psftp.c
@ -491,7 +491,7 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart)
|
|||||||
struct sftp_request *req;
|
struct sftp_request *req;
|
||||||
uint64 offset;
|
uint64 offset;
|
||||||
RFile *file;
|
RFile *file;
|
||||||
int ret, err, eof;
|
int ret, err = 0, eof;
|
||||||
struct fxp_attrs attrs;
|
struct fxp_attrs attrs;
|
||||||
long permissions;
|
long permissions;
|
||||||
|
|
||||||
@ -651,11 +651,12 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart)
|
|||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
printf("read size of %s: %s\n", outfname, fxp_error());
|
printf("read size of %s: %s\n", outfname, fxp_error());
|
||||||
|
err = 1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (!(attrs.flags & SSH_FILEXFER_ATTR_SIZE)) {
|
if (!(attrs.flags & SSH_FILEXFER_ATTR_SIZE)) {
|
||||||
printf("read size of %s: size was not given\n", outfname);
|
printf("read size of %s: size was not given\n", outfname);
|
||||||
ret = 0;
|
err = 1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
offset = attrs.size;
|
offset = attrs.size;
|
||||||
@ -674,9 +675,8 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart)
|
|||||||
* FIXME: we can use FXP_FSTAT here to get the file size, and
|
* FIXME: we can use FXP_FSTAT here to get the file size, and
|
||||||
* thus put up a progress bar.
|
* thus put up a progress bar.
|
||||||
*/
|
*/
|
||||||
ret = 1;
|
|
||||||
xfer = xfer_upload_init(fh, offset);
|
xfer = xfer_upload_init(fh, offset);
|
||||||
err = eof = 0;
|
eof = 0;
|
||||||
while ((!err && !eof) || !xfer_done(xfer)) {
|
while ((!err && !eof) || !xfer_done(xfer)) {
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
int len, ret;
|
int len, ret;
|
||||||
@ -716,7 +716,7 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart)
|
|||||||
|
|
||||||
close_rfile(file);
|
close_rfile(file);
|
||||||
|
|
||||||
return ret;
|
return (err == 0) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user