Fix file-extension check
If the extension is not found, string::rfind() returns -1, That can still match unrelated file if the file-name is one char longer than an arbitrary extension. eg. "foo" matched ".aiff" because -1 = strlen("foo") - strlen(".aiff") Also due to a missing comma ".VOC.vwe" matched any file shorter than 7 chars in length.
This commit is contained in:
parent
9f7114f761
commit
6b6ae5dedb
@ -331,7 +331,7 @@ AudioFileSource::safe_audio_file_extension(const string& file)
|
||||
".smp", ".SMP",
|
||||
".snd", ".SND",
|
||||
".maud", ".MAUD",
|
||||
".voc", ".VOC"
|
||||
".voc", ".VOC",
|
||||
".vwe", ".VWE",
|
||||
".w64", ".W64",
|
||||
".wav", ".WAV",
|
||||
@ -352,7 +352,8 @@ AudioFileSource::safe_audio_file_extension(const string& file)
|
||||
};
|
||||
|
||||
for (size_t n = 0; n < sizeof(suffixes)/sizeof(suffixes[0]); ++n) {
|
||||
if (file.rfind (suffixes[n]) == file.length() - strlen (suffixes[n])) {
|
||||
size_t pos = file.rfind (suffixes[n]);
|
||||
if (pos > 0 && pos == file.length() - strlen(suffixes[n])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,8 @@ FFMPEGFileSource::safe_audio_file_extension (const std::string &file)
|
||||
};
|
||||
|
||||
for (size_t n = 0; n < sizeof(suffixes) / sizeof(suffixes[0]); ++n) {
|
||||
if (file.rfind(suffixes[n]) == file.length() - strlen(suffixes[n])) {
|
||||
size_t pos = file.rfind (suffixes[n]);
|
||||
if (pos > 0 && pos == file.length() - strlen(suffixes[n])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user