ReadTIFFImage bug

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Oleksiis
Posts: 2
Joined: 2012-03-13T10:00:53-07:00
Authentication code: 8675308

ReadTIFFImage bug

Post 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++;
          }
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: ReadTIFFImage bug

Post by magick »

We can reproduce the problem you posted and will have a patch by sometime tomorrow. Thanks.
Post Reply