ImBuf: replace incorrect strstr use with memcmp

Besides being incorrect as only the first two bytes should be tested,
searching binary data using `strstr` can easily read past buffer bounds.
This commit is contained in:
Campbell Barton 2020-11-11 14:08:53 +11:00 committed by Jeroen Bakker
parent 8b59119e10
commit 13b02a724f
Notes: blender-bot 2023-02-13 22:19:24 +01:00
Referenced by issue #77348, Blender LTS: Maintenance Task 2.83
1 changed files with 1 additions and 1 deletions

View File

@ -203,7 +203,7 @@ int imb_is_a_hdr(const unsigned char *buf)
/* update: actually, the 'RADIANCE' part is just an optional program name,
* the magic word is really only the '#?' part */
// if (strstr((char *)buf, "#?RADIANCE")) return 1;
if (strstr((char *)buf, "#?")) {
if (memcmp((char *)buf, "#?", 2) == 0) {
return 1;
}
// if (strstr((char *)buf, "32-bit_rle_rgbe")) return 1;