1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-06-30 19:12: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

@ -341,6 +341,17 @@ void finish_wildcard_matching(WildcardMatcher *dir) {
sfree(dir);
}
int vet_filename(char *name)
{
if (strchr(name, '/'))
return FALSE;
if (name[0] == '.' && (!name[1] || (name[1] == '.' && !name[2])))
return FALSE;
return TRUE;
}
int create_directory(char *name)
{
return mkdir(name, 0777) == 0;