LogicAndTrick / sledge-formats

C# parsers and formats for Half-Life 1 and related engines.
MIT License
71 stars 10 forks source link

Clamp lightmap size to prevent buffer over-read #14

Closed SamVanheer closed 1 year ago

SamVanheer commented 1 year ago

This clamps the size of the lightmap data array in case the lightmap data is being read from the end of the BSP file lightmap data array.

I've tried to adjust the lightmap width and height accordingly but it's a guessing game at best. The problem is that lightmaps are being stored as Lightmap objects as textures with integer width and height, whereas actual lightmaps are subrects with fractional width and height in a larger image.

It may be necessary to change how lightmaps are converted to account for this.

See SamVanheer/HalfLife.UnifiedSdk.MapDecompiler#21

LogicAndTrick commented 1 year ago

Thanks!