engine: imagelib: fix pixel iteration bounds checking on 1-bit BMPs

move 1-bit BMP bounds checking to the beginning of a loop to prevent a second iteration

Fixes: [GHSA-3p7j-2339-g5mm](https://github.com/FWGS/xash3d-fwgs/security/advisories/GHSA-3p7j-2339-g5mm)
Signed-off-by: veygax <veyga@veygax.dev>
This commit is contained in:
veygax
2025-11-14 22:44:23 +00:00
committed by a1batross
parent 747baa1e16
commit 0c3c6345e9

View File

@@ -219,13 +219,13 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesi
column--; // ingnore main iterations
for( c = 0, k = 128; c < 8; c++, k >>= 1 )
{
if( ++column >= columns )
break;
red = green = blue = (!!(alpha & k) == 1 ? 0xFF : 0x00);
*pixbuf++ = red;
*pixbuf++ = green;
*pixbuf++ = blue;
*pixbuf++ = 0x00;
if( ++column == columns )
break;
}
break;
case 4: