safety check for basename function
This commit is contained in:
parent
312858eb1c
commit
d7124edb5a
@ -178,6 +178,10 @@ ReturnValue_t HostFilesystem::isDirectory(const char *path, bool &isDirectory) {
|
||||
ReturnValue_t HostFilesystem::getBaseFilename(FilesystemParams params, char *nameBuf, size_t maxLen,
|
||||
size_t &baseNameLen) {
|
||||
std::string path(params.path);
|
||||
size_t lastPos = path.find_last_of("/\\");
|
||||
if (lastPos == std::string::npos) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
std::string baseName = path.substr(path.find_last_of("/\\") + 1);
|
||||
if (baseName.size() + 1 > maxLen) {
|
||||
return returnvalue::FAILED;
|
||||
|
Loading…
Reference in New Issue
Block a user