fix pester test failures

This commit is contained in:
Tess Gauthier 2022-09-13 17:50:40 -04:00
parent 215341dd66
commit f4d2ff0409
2 changed files with 21 additions and 8 deletions

View File

@ -268,14 +268,27 @@ readdir(void *avp)
char *
basename(char *path)
{
char *pdest;
char *pdest;
const char *endp;
static char bname[PATH_MAX];
/* Find any trailing slashes */
endp = path + strlen(path) - 1;
while (endp > path && (*endp == '/' || *endp == '\\'))
endp--;
int path_len = endp - path + 1;
if (strncpy_s(bname, PATH_MAX, path, path_len + 1)) {
return NULL;
}
bname[path_len] = '\0';
if (!path)
return ".";
pdest = strrchr(path, '/');
pdest = strrchr(bname, '/');
if (pdest)
return (pdest + 1);
pdest = strrchr(path, '\\');
pdest = strrchr(bname, '\\');
if (pdest)
return (pdest + 1);

View File

@ -1819,6 +1819,11 @@ do_download(struct sftp_conn *conn, const char *remote_path,
status = SSH2_FX_FAILURE;
else
status = SSH2_FX_OK;
#ifdef WINDOWS
if (add_mark_of_web(local_path) == -1) {
debug("%s: failed to add mark of the web", local_path);
}
#endif // WINDOWS
/* Override umask and utimes if asked */
#ifdef HAVE_FCHMOD
if (preserve_flag && fchmod(local_fd, mode) == -1)
@ -1847,11 +1852,6 @@ do_download(struct sftp_conn *conn, const char *remote_path,
}
}
close(local_fd);
#ifdef WINDOWS
if (add_mark_of_web(local_path) == -1) {
debug("%s: failed to add mark of the web", local_path);
}
#endif // WINDOWS
sshbuf_free(msg);
free(handle);