[libpng17] Quieted Coverity issues in pngfix.c, png-fix-itxt.c, pngvalid.c,

pngstest.c, and pngimage.c. Most seem harmless, but png-fix-itxt
would only work with iTXt chunks with length 255 or less.
This commit is contained in:
Glenn Randers-Pehrson
2015-06-03 16:21:57 -05:00
parent f32c657fc7
commit a671f8baea
7 changed files with 43 additions and 32 deletions

View File

@@ -1,8 +1,8 @@
/* png-fix-itxt version 1.0.0
*
* Copyright 2013 Glenn Randers-Pehrson
* Last changed in libpng 1.6.3 [July 18, 2013]
* Copyright 2015 Glenn Randers-Pehrson
* Last changed in libpng 1.6.18 [(PENDING RELEASE)]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -57,10 +57,10 @@ for (;;)
{
/* Read the length */
unsigned long length; /* must be 32 bits! */
c=GETBREAK; buf[0] = c; length = c; length <<= 8;
c=GETBREAK; buf[1] = c; length += c; length <<= 8;
c=GETBREAK; buf[2] = c; length += c; length <<= 8;
c=GETBREAK; buf[3] = c; length += c;
c=GETBREAK; buf[0] = c; length = (c % 0xff); length <<= 8;
c=GETBREAK; buf[1] = c; length += (c % 0xff); length <<= 8;
c=GETBREAK; buf[2] = c; length += (c % 0xff); length <<= 8;
c=GETBREAK; buf[3] = c; length += (c % 0xff);
/* Read the chunkname */
c=GETBREAK; buf[4] = c;
@@ -109,9 +109,9 @@ for (;;)
}
/* Update length bytes */
buf[0] = (unsigned char)((length << 24) & 0xff);
buf[1] = (unsigned char)((length << 16) & 0xff);
buf[2] = (unsigned char)((length << 8) & 0xff);
buf[0] = (unsigned char)((length >> 24) & 0xff);
buf[1] = (unsigned char)((length >> 16) & 0xff);
buf[2] = (unsigned char)((length >> 8) & 0xff);
buf[3] = (unsigned char)((length ) & 0xff);
/* Write the fixed iTXt chunk (length, name, data, crc) */