mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-12 16:34:44 +02:00
GHSL-2023-092: Check if i is not bigger than datalen
This commit is contained in:
parent
9e24ec55db
commit
d7ea26d931
@ -1403,8 +1403,11 @@ LangType FileManager::detectLanguageFromTextBegining(const unsigned char *data,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (i == dataLen)
|
||||||
|
return L_TEXT;
|
||||||
|
|
||||||
// Create the buffer to need to test
|
// Create the buffer to need to test
|
||||||
const size_t longestLength = 40; // shebangs can be large
|
const size_t longestLength = std::min<size_t>(40, dataLen - i); // shebangs can be large
|
||||||
std::string buf2Test = std::string((const char *)data + i, longestLength);
|
std::string buf2Test = std::string((const char *)data + i, longestLength);
|
||||||
|
|
||||||
// Is there a \r or \n in the buffer? If so, truncate it
|
// Is there a \r or \n in the buffer? If so, truncate it
|
||||||
|
Loading…
x
Reference in New Issue
Block a user