Re: [PATCH 0/5] v4l2 JPEG helpers and CODA960 JPEG decoder

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andrzej,

On Wed, 18 Mar 2020, Andrzej Pietrasiewicz <andrzejtp2010@xxxxxxxxx> wrote:
Hi Adrian, W dniu 18.03.2020 o 11:41, Adrian Ratiu pisze: > Hi Philipp, > > Further testing revealed the decoder rejects jpegs with > optimized huffman tables, but the following decoder patch > makes them work. > > Feel free to include these changes in your next version. > > Adrian > > drivers/media/platform/coda/coda-jpeg.c | 10 +++++----- 1 > file changed, 5 insertions(+), 5 deletions(-)>> > > diff --git a/drivers/media/platform/coda/coda-jpeg.c > b/drivers/media/platform <snip> > } - if (huffman_tables[i].length != > ((i & 2) ? 178 : 28)) { + if > (huffman_tables[i].length < 17) { v4l2_err(&dev->v4l2_dev, > "invalid Huffman table %d length: %zu\n", i, > huffman_tables[i].length); Shouldn't you also be checking the upper bound on the table length, to ensure that you won't exceed the memcpy() destination's capacity below?

Good point, it's always good to have an upper bound sanity check test, even though in practice the optimized tables are smaller than the std ones by definition, there are never enough checks against bugs :)

Thanks,
Adrian


<snip>

 > -	memcpy(huff_tab->dc_values[0], huffman_tables[0].start + 16, 12);
> + memcpy(huff_tab->dc_values[0], huffman_tables[0].start + 16, huffman_tables[0].length - 16);


Andrzej



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux