bhuvneshgarg / openjpeg

Automatically exported from code.google.com/p/openjpeg
Other
0 stars 0 forks source link

Bug in tiff reading method in convert.c #449

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In the following block of code:

if((index < imgsize)&(index+1 < imgsize))
{
 image->comps[0].data[index]   = ( dat8[i+0]<<4 )        |(dat8[i+1]>>4);
 image->comps[1].data[index]   = ((dat8[i+1]& 0x0f)<< 8) | dat8[i+2];

 image->comps[2].data[index]   = ( dat8[i+3]<<4)         |(dat8[i+4]>>4);
 image->comps[0].data[index+1] = ((dat8[i+4]& 0x0f)<< 8) | dat8[i+5];

 image->comps[1].data[index+1] = ( dat8[i+6] <<4)        |(dat8[i+7]>>4);
 image->comps[2].data[index+1] = ((dat8[i+7]& 0x0f)<< 8) | dat8[i+8];
 index += 2;
}

In first line, it should be logical and, not bitwise and.

In fact, we don't need the line (index < imgSize) at all.

Original issue reported on code.google.com by boxe...@gmail.com on 10 Dec 2014 at 3:43

GoogleCodeExporter commented 9 years ago
Aaron,

I'll only correct the logical && for now.

The other suggestion seems valid but for overflow checking (we're talking about 
signed values so it might not apply given the C standard), I'll let it live 
like this. It might be modified with Issue 264 anyway.

Original comment by m.darb...@gmail.com on 11 Dec 2014 at 8:01

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r2954.

Original comment by m.darb...@gmail.com on 11 Dec 2014 at 8:21

GoogleCodeExporter commented 9 years ago
Hi Matthieu,

Actually, yes, you're right, you do need both conditions. In case imgSize is 
odd.

But, if imgSize is odd, we have another bug:  the last line will be cut off by 
this
method.  For 12 bit Cinema files.  

Not sure how important this is though.

I will open another issue.

Cheers,
Aaron

Original comment by boxe...@gmail.com on 11 Dec 2014 at 11:31