mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 11:32:48 -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:
7
pscp.c
7
pscp.c
@ -1696,7 +1696,8 @@ static void rsource(const char *src)
|
||||
if (scp_send_dirname(last, 0755))
|
||||
return;
|
||||
|
||||
dir = open_directory(src);
|
||||
const char *opendir_err;
|
||||
dir = open_directory(src, &opendir_err);
|
||||
if (dir != NULL) {
|
||||
char *filename;
|
||||
while ((filename = read_filename(dir)) != NULL) {
|
||||
@ -1705,8 +1706,10 @@ static void rsource(const char *src)
|
||||
sfree(foundfile);
|
||||
sfree(filename);
|
||||
}
|
||||
close_directory(dir);
|
||||
} else {
|
||||
tell_user(stderr, "Error opening directory %s: %s", src, opendir_err);
|
||||
}
|
||||
close_directory(dir);
|
||||
|
||||
(void) scp_send_enddir();
|
||||
|
||||
|
Reference in New Issue
Block a user