From aba1050bae1a1dc0aee0a72d275933a8f6b41254 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Sat, 5 Jun 2021 17:11:35 +0200 Subject: [PATCH] Throw exception for single channel tiff when bits per sample is larger then 16 --- .../Formats/Tiff/TiffDecoderOptionsParser.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs index 3ba64b18cb..014dd55380 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs @@ -105,6 +105,11 @@ namespace SixLabors.ImageSharp.Formats.Tiff } ushort bitsPerChannel = options.BitsPerSample[0]; + if (bitsPerChannel > 16) + { + TiffThrowHelper.ThrowNotSupported("Bits per sample is not supported."); + } + switch (bitsPerChannel) { case 8: @@ -143,6 +148,11 @@ namespace SixLabors.ImageSharp.Formats.Tiff } ushort bitsPerChannel = options.BitsPerSample[0]; + if (bitsPerChannel > 16) + { + TiffThrowHelper.ThrowNotSupported("Bits per sample is not supported."); + } + switch (bitsPerChannel) { case 8: