mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-04 04:52:47 -05:00
xfer_{up,down}load_gotpkt free their input sftp_packet as a side
effect of handling it, but they do not free it if it isn't a packet they recognise as part of their upload/download. Invent a return value that specifically signals this, and consistently free pktin at every call site if that return value comes back. Also, ensure that that return value also always comes with something meaningful in fxp_error. [originally from svn r9915]
This commit is contained in:
12
psftp.c
12
psftp.c
@ -468,6 +468,8 @@ int sftp_get_file(char *fname, char *outfname, int recurse, int restart)
|
||||
printf("error while reading: %s\n", fxp_error());
|
||||
shown_err = TRUE;
|
||||
}
|
||||
if (ret == INT_MIN) /* pktin not even freed */
|
||||
sfree(pktin);
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
@ -720,9 +722,13 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart)
|
||||
if (!xfer_done(xfer)) {
|
||||
pktin = sftp_recv();
|
||||
ret = xfer_upload_gotpkt(xfer, pktin);
|
||||
if (ret <= 0 && !err) {
|
||||
printf("error while writing: %s\n", fxp_error());
|
||||
err = 1;
|
||||
if (ret <= 0) {
|
||||
if (ret == INT_MIN) /* pktin not even freed */
|
||||
sfree(pktin);
|
||||
if (!err) {
|
||||
printf("error while writing: %s\n", fxp_error());
|
||||
err = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user