Page 1 of 1

ReadTIFFImage bug

Posted: 2012-03-13T10:17:37-07:00
by Oleksiis
While compiling IM on Visual Studio 2010 I noticed a some suspicious C4333 warnings meaning "A right shift operation was too large an amount. All significant bits are shifted out and the result will always be zero."
The code below in the tiff.c file (ReadStripMethod, line 1466+) looks logically incorrect because (*p) is unsigned char and TIFFGetG, TIFFGetB and TIFFGetA will always return 0. Also it looks like p pointer should be increased by 4 bytes, not just 1...

Code: Select all

          p=(unsigned char *) (((uint32 *) pixels)+image->columns*i);
          for (x=0; x < (ssize_t) image->columns; x++)
          {
            SetPixelRed(q,ScaleCharToQuantum((unsigned char)
              (TIFFGetR(*p))));
            SetPixelGreen(q,ScaleCharToQuantum((unsigned char)
              (TIFFGetG(*p))));
            SetPixelBlue(q,ScaleCharToQuantum((unsigned char)
              (TIFFGetB(*p))));
            if (image->matte != MagickFalse)
              SetPixelOpacity(q,ScaleCharToQuantum((unsigned char)
                (TIFFGetA(*p))));
            p++;
            q++;
          }

Re: ReadTIFFImage bug

Posted: 2012-03-13T17:54:31-07:00
by magick
We can reproduce the problem you posted and will have a patch by sometime tomorrow. Thanks.