@@ -570,4 +570,32 @@ public void BmpDecoder_ThrowsException_Issue2696<TPixel>(TestImageProvider<TPixe
570570 } ) ;
571571 Assert . IsType < InvalidMemoryOperationException > ( ex . InnerException ) ;
572572 }
573+
574+ // https://github.com/SixLabors/ImageSharp/issues/3074
575+ [ Fact ]
576+ public void BmpDecoder_ThrowsException_Issue3074 ( )
577+ {
578+ // Crafted BMP: pixel data offset = 0x7FFFFFFF, actual file = 35 bytes
579+ byte [ ] data =
580+ [
581+ 0x42 , 0x4D , // "BM" signature
582+ 0x3A , 0x00 , 0x00 , 0x00 , // file size: 58
583+ 0x00 , 0x00 , 0x00 , 0x00 , // reserved
584+ 0xFF , 0xFF , 0xFF , 0x7F , // pixel offset: 0x7FFFFFFF (2,147,483,647)
585+ 0x28 , 0x00 , 0x00 , 0x00 , // DIB header size: 40
586+ 0x01 , 0x00 , 0x00 , 0x00 , // width: 1
587+ 0x01 , 0xFF , 0x00 , 0x00 , // height: 65281
588+ 0x01 , 0x00 , // color planes: 1
589+ 0x08 , 0x00 , // bits per pixel: 8
590+ 0x00 , 0x00 , 0x00 , 0x00 , // compression: RGB
591+ 0x00 , 0x00 , 0x00 // (truncated)
592+ ] ;
593+
594+ using MemoryStream stream = new ( data ) ;
595+
596+ Assert . Throws < InvalidImageContentException > ( ( ) =>
597+ {
598+ using Image < Rgba32 > image = Image . Load < Rgba32 > ( stream ) ;
599+ } ) ;
600+ }
573601}
0 commit comments