mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Handle failed SSH_FXP_CLOSE requests in sftp_put_file.
It is possible for SSH_FXP_CLOSE requests to fail. This can happen if the server buffers writes and an error occurs flushing the data to disk while processing the SSH_FXP_CLOSE request. If the close fails, sftp_put_file now returns an error as well.
This commit is contained in:
parent
e9a76883ad
commit
6f871e3d22
8
psftp.c
8
psftp.c
@ -712,7 +712,13 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart)
|
||||
cleanup:
|
||||
req = fxp_close_send(fh);
|
||||
pktin = sftp_wait_for_reply(req);
|
||||
fxp_close_recv(pktin, req);
|
||||
ret = fxp_close_recv(pktin, req);
|
||||
if (!ret) {
|
||||
if (!err) {
|
||||
printf("error while closing: %s", fxp_error());
|
||||
err = 1;
|
||||
}
|
||||
}
|
||||
|
||||
close_rfile(file);
|
||||
|
||||
|
3
sftp.c
3
sftp.c
@ -658,11 +658,12 @@ struct sftp_request *fxp_close_send(struct fxp_handle *handle)
|
||||
return req;
|
||||
}
|
||||
|
||||
void fxp_close_recv(struct sftp_packet *pktin, struct sftp_request *req)
|
||||
int fxp_close_recv(struct sftp_packet *pktin, struct sftp_request *req)
|
||||
{
|
||||
sfree(req);
|
||||
fxp_got_status(pktin);
|
||||
sftp_pkt_free(pktin);
|
||||
return fxp_errtype == SSH_FX_OK;
|
||||
}
|
||||
|
||||
struct sftp_request *fxp_mkdir_send(const char *path)
|
||||
|
4
sftp.h
4
sftp.h
@ -149,10 +149,10 @@ struct fxp_handle *fxp_opendir_recv(struct sftp_packet *pktin,
|
||||
struct sftp_request *req);
|
||||
|
||||
/*
|
||||
* Close a file/dir.
|
||||
* Close a file/dir. Returns 1 on success, 0 on error.
|
||||
*/
|
||||
struct sftp_request *fxp_close_send(struct fxp_handle *handle);
|
||||
void fxp_close_recv(struct sftp_packet *pktin, struct sftp_request *req);
|
||||
int fxp_close_recv(struct sftp_packet *pktin, struct sftp_request *req);
|
||||
|
||||
/*
|
||||
* Make a directory.
|
||||
|
Loading…
Reference in New Issue
Block a user