mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-04 04:52:47 -05:00
pscp: replace crash with diagnostic on opendir failure.
A user points out that the call to close_directory() in pscp.c's rsource() function should have been inside rather than outside the if statement that checks whether the directory handle is NULL. As a result, any failed attempt to open a directory during a 'pscp -r' recursive upload leads to a null-pointer dereference. Moved the close_directory call to where it should be, and also arranged to print the OS error code if the directory-open fails, by also changing the API of open_directory to return an error string on failure.
This commit is contained in:
5
psftp.c
5
psftp.c
@ -533,6 +533,7 @@ bool sftp_put_file(char *fname, char *outfname, bool recurse, bool restart)
|
||||
bool result;
|
||||
int nnames, namesize;
|
||||
char *name, **ournames;
|
||||
const char *opendir_err;
|
||||
DirHandle *dh;
|
||||
int i;
|
||||
|
||||
@ -563,9 +564,9 @@ bool sftp_put_file(char *fname, char *outfname, bool recurse, bool restart)
|
||||
nnames = namesize = 0;
|
||||
ournames = NULL;
|
||||
|
||||
dh = open_directory(fname);
|
||||
dh = open_directory(fname, &opendir_err);
|
||||
if (!dh) {
|
||||
printf("%s: unable to open directory\n", fname);
|
||||
printf("%s: unable to open directory: %s\n", fname, opendir_err);
|
||||
return false;
|
||||
}
|
||||
while ((name = read_filename(dh)) != NULL) {
|
||||
|
Reference in New Issue
Block a user