Improved filename validation

This commit is contained in:
Uwe Seimet 2021-09-17 19:59:12 +02:00
parent 9663144c45
commit 5b3af7cf9d

View File

@ -717,8 +717,12 @@ string SetReservedIds(const string& ids)
bool IsValidFilename(const string& filename)
{
if (filename == "." || filename == "..") {
return false;
}
struct stat st;
return !stat(filename.c_str(), &st) && S_ISREG(st.st_mode);
return stat(filename.c_str(), &st) || !S_ISREG(st.st_mode);
}
bool CreateImage(int fd, const PbCommand& command)