1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 03:22:48 -05:00

General mechanism for ensuring a dodgy SFTP server can't return

malicious filenames via FXP_READDIR.

[originally from svn r4995]
This commit is contained in:
Simon Tatham
2004-12-16 19:36:47 +00:00
parent 5ea746b15d
commit 6c81ee6706
5 changed files with 59 additions and 14 deletions

View File

@ -445,6 +445,17 @@ void finish_wildcard_matching(WildcardMatcher *dir)
sfree(dir);
}
int vet_filename(char *name)
{
if (strchr(name, '/') || strchr(name, '\\') || strchr(name, ':'))
return FALSE;
if (!name[strspn(name, ".")]) /* entirely composed of dots */
return FALSE;
return TRUE;
}
int create_directory(char *name)
{
return CreateDirectory(name, NULL) != 0;