New upstream version libtiff-4.0.4beta (#1186219)
Signed-off-by: Petr Hracek <phracek@redhat.com>
This commit is contained in:
parent
aaa467f8bb
commit
9dbb5814ab
@ -1,40 +0,0 @@
|
||||
Upstream patch for CVE-2012-4447.
|
||||
|
||||
|
||||
diff -Naur tiff-4.0.3.orig/libtiff/tif_pixarlog.c tiff-4.0.3/libtiff/tif_pixarlog.c
|
||||
--- tiff-4.0.3.orig/libtiff/tif_pixarlog.c 2012-07-04 15:26:31.000000000 -0400
|
||||
+++ tiff-4.0.3/libtiff/tif_pixarlog.c 2012-12-12 16:43:18.931315699 -0500
|
||||
@@ -644,6 +644,20 @@
|
||||
return bytes;
|
||||
}
|
||||
|
||||
+static tmsize_t
|
||||
+add_ms(tmsize_t m1, tmsize_t m2)
|
||||
+{
|
||||
+ tmsize_t bytes = m1 + m2;
|
||||
+
|
||||
+ /* if either input is zero, assume overflow already occurred */
|
||||
+ if (m1 == 0 || m2 == 0)
|
||||
+ bytes = 0;
|
||||
+ else if (bytes <= m1 || bytes <= m2)
|
||||
+ bytes = 0;
|
||||
+
|
||||
+ return bytes;
|
||||
+}
|
||||
+
|
||||
static int
|
||||
PixarLogFixupTags(TIFF* tif)
|
||||
{
|
||||
@@ -671,9 +685,11 @@
|
||||
td->td_samplesperpixel : 1);
|
||||
tbuf_size = multiply_ms(multiply_ms(multiply_ms(sp->stride, td->td_imagewidth),
|
||||
td->td_rowsperstrip), sizeof(uint16));
|
||||
+ /* add one more stride in case input ends mid-stride */
|
||||
+ tbuf_size = add_ms(tbuf_size, sizeof(uint16) * sp->stride);
|
||||
if (tbuf_size == 0)
|
||||
return (0); /* TODO: this is an error return without error report through TIFFErrorExt */
|
||||
- sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size+sizeof(uint16)*sp->stride);
|
||||
+ sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size);
|
||||
if (sp->tbuf == NULL)
|
||||
return (0);
|
||||
if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
|
@ -1,86 +0,0 @@
|
||||
Upstream patch for CVE-2012-4564.
|
||||
|
||||
|
||||
diff -Naur tiff-4.0.3.orig/tools/ppm2tiff.c tiff-4.0.3/tools/ppm2tiff.c
|
||||
--- tiff-4.0.3.orig/tools/ppm2tiff.c 2010-04-10 15:22:34.000000000 -0400
|
||||
+++ tiff-4.0.3/tools/ppm2tiff.c 2012-12-12 16:43:18.932315708 -0500
|
||||
@@ -72,6 +72,17 @@
|
||||
exit(-2);
|
||||
}
|
||||
|
||||
+static tmsize_t
|
||||
+multiply_ms(tmsize_t m1, tmsize_t m2)
|
||||
+{
|
||||
+ tmsize_t bytes = m1 * m2;
|
||||
+
|
||||
+ if (m1 && bytes / m1 != m2)
|
||||
+ bytes = 0;
|
||||
+
|
||||
+ return bytes;
|
||||
+}
|
||||
+
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
@@ -79,7 +90,7 @@
|
||||
uint32 rowsperstrip = (uint32) -1;
|
||||
double resolution = -1;
|
||||
unsigned char *buf = NULL;
|
||||
- tsize_t linebytes = 0;
|
||||
+ tmsize_t linebytes = 0;
|
||||
uint16 spp = 1;
|
||||
uint16 bpp = 8;
|
||||
TIFF *out;
|
||||
@@ -89,6 +100,7 @@
|
||||
int c;
|
||||
extern int optind;
|
||||
extern char* optarg;
|
||||
+ tmsize_t scanline_size;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "%s: Too few arguments\n", argv[0]);
|
||||
@@ -221,7 +233,8 @@
|
||||
}
|
||||
switch (bpp) {
|
||||
case 1:
|
||||
- linebytes = (spp * w + (8 - 1)) / 8;
|
||||
+ /* if round-up overflows, result will be zero, OK */
|
||||
+ linebytes = (multiply_ms(spp, w) + (8 - 1)) / 8;
|
||||
if (rowsperstrip == (uint32) -1) {
|
||||
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, h);
|
||||
} else {
|
||||
@@ -230,15 +243,31 @@
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
- linebytes = spp * w;
|
||||
+ linebytes = multiply_ms(spp, w);
|
||||
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP,
|
||||
TIFFDefaultStripSize(out, rowsperstrip));
|
||||
break;
|
||||
}
|
||||
- if (TIFFScanlineSize(out) > linebytes)
|
||||
+ if (linebytes == 0) {
|
||||
+ fprintf(stderr, "%s: scanline size overflow\n", infile);
|
||||
+ (void) TIFFClose(out);
|
||||
+ exit(-2);
|
||||
+ }
|
||||
+ scanline_size = TIFFScanlineSize(out);
|
||||
+ if (scanline_size == 0) {
|
||||
+ /* overflow - TIFFScanlineSize already printed a message */
|
||||
+ (void) TIFFClose(out);
|
||||
+ exit(-2);
|
||||
+ }
|
||||
+ if (scanline_size < linebytes)
|
||||
buf = (unsigned char *)_TIFFmalloc(linebytes);
|
||||
else
|
||||
- buf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out));
|
||||
+ buf = (unsigned char *)_TIFFmalloc(scanline_size);
|
||||
+ if (buf == NULL) {
|
||||
+ fprintf(stderr, "%s: Not enough memory\n", infile);
|
||||
+ (void) TIFFClose(out);
|
||||
+ exit(-2);
|
||||
+ }
|
||||
if (resolution > 0) {
|
||||
TIFFSetField(out, TIFFTAG_XRESOLUTION, resolution);
|
||||
TIFFSetField(out, TIFFTAG_YRESOLUTION, resolution);
|
@ -1,145 +0,0 @@
|
||||
diff -Naur tiff-4.0.3.orig/tools/tiff2pdf.c tiff-4.0.3/tools/tiff2pdf.c
|
||||
--- tiff-4.0.3.orig/tools/tiff2pdf.c 2012-07-25 22:56:43.000000000 -0400
|
||||
+++ tiff-4.0.3/tools/tiff2pdf.c 2013-05-02 12:04:49.057090227 -0400
|
||||
@@ -3341,33 +3341,56 @@
|
||||
uint32 height){
|
||||
|
||||
tsize_t i=0;
|
||||
- uint16 ri =0;
|
||||
- uint16 v_samp=1;
|
||||
- uint16 h_samp=1;
|
||||
- int j=0;
|
||||
-
|
||||
- i++;
|
||||
-
|
||||
- while(i<(*striplength)){
|
||||
+
|
||||
+ while (i < *striplength) {
|
||||
+ tsize_t datalen;
|
||||
+ uint16 ri;
|
||||
+ uint16 v_samp;
|
||||
+ uint16 h_samp;
|
||||
+ int j;
|
||||
+ int ncomp;
|
||||
+
|
||||
+ /* marker header: one or more FFs */
|
||||
+ if (strip[i] != 0xff)
|
||||
+ return(0);
|
||||
+ i++;
|
||||
+ while (i < *striplength && strip[i] == 0xff)
|
||||
+ i++;
|
||||
+ if (i >= *striplength)
|
||||
+ return(0);
|
||||
+ /* SOI is the only pre-SOS marker without a length word */
|
||||
+ if (strip[i] == 0xd8)
|
||||
+ datalen = 0;
|
||||
+ else {
|
||||
+ if ((*striplength - i) <= 2)
|
||||
+ return(0);
|
||||
+ datalen = (strip[i+1] << 8) | strip[i+2];
|
||||
+ if (datalen < 2 || datalen >= (*striplength - i))
|
||||
+ return(0);
|
||||
+ }
|
||||
switch( strip[i] ){
|
||||
- case 0xd8:
|
||||
- /* SOI - start of image */
|
||||
+ case 0xd8: /* SOI - start of image */
|
||||
_TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), 2);
|
||||
*bufferoffset+=2;
|
||||
- i+=2;
|
||||
break;
|
||||
- case 0xc0:
|
||||
- case 0xc1:
|
||||
- case 0xc3:
|
||||
- case 0xc9:
|
||||
- case 0xca:
|
||||
+ case 0xc0: /* SOF0 */
|
||||
+ case 0xc1: /* SOF1 */
|
||||
+ case 0xc3: /* SOF3 */
|
||||
+ case 0xc9: /* SOF9 */
|
||||
+ case 0xca: /* SOF10 */
|
||||
if(no==0){
|
||||
- _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), strip[i+2]+2);
|
||||
- for(j=0;j<buffer[*bufferoffset+9];j++){
|
||||
- if( (buffer[*bufferoffset+11+(2*j)]>>4) > h_samp)
|
||||
- h_samp = (buffer[*bufferoffset+11+(2*j)]>>4);
|
||||
- if( (buffer[*bufferoffset+11+(2*j)] & 0x0f) > v_samp)
|
||||
- v_samp = (buffer[*bufferoffset+11+(2*j)] & 0x0f);
|
||||
+ _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), datalen+2);
|
||||
+ ncomp = buffer[*bufferoffset+9];
|
||||
+ if (ncomp < 1 || ncomp > 4)
|
||||
+ return(0);
|
||||
+ v_samp=1;
|
||||
+ h_samp=1;
|
||||
+ for(j=0;j<ncomp;j++){
|
||||
+ uint16 samp = buffer[*bufferoffset+11+(3*j)];
|
||||
+ if( (samp>>4) > h_samp)
|
||||
+ h_samp = (samp>>4);
|
||||
+ if( (samp & 0x0f) > v_samp)
|
||||
+ v_samp = (samp & 0x0f);
|
||||
}
|
||||
v_samp*=8;
|
||||
h_samp*=8;
|
||||
@@ -3381,45 +3404,43 @@
|
||||
(unsigned char) ((height>>8) & 0xff);
|
||||
buffer[*bufferoffset+6]=
|
||||
(unsigned char) (height & 0xff);
|
||||
- *bufferoffset+=strip[i+2]+2;
|
||||
- i+=strip[i+2]+2;
|
||||
-
|
||||
+ *bufferoffset+=datalen+2;
|
||||
+ /* insert a DRI marker */
|
||||
buffer[(*bufferoffset)++]=0xff;
|
||||
buffer[(*bufferoffset)++]=0xdd;
|
||||
buffer[(*bufferoffset)++]=0x00;
|
||||
buffer[(*bufferoffset)++]=0x04;
|
||||
buffer[(*bufferoffset)++]=(ri >> 8) & 0xff;
|
||||
buffer[(*bufferoffset)++]= ri & 0xff;
|
||||
- } else {
|
||||
- i+=strip[i+2]+2;
|
||||
}
|
||||
break;
|
||||
- case 0xc4:
|
||||
- case 0xdb:
|
||||
- _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), strip[i+2]+2);
|
||||
- *bufferoffset+=strip[i+2]+2;
|
||||
- i+=strip[i+2]+2;
|
||||
+ case 0xc4: /* DHT */
|
||||
+ case 0xdb: /* DQT */
|
||||
+ _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), datalen+2);
|
||||
+ *bufferoffset+=datalen+2;
|
||||
break;
|
||||
- case 0xda:
|
||||
+ case 0xda: /* SOS */
|
||||
if(no==0){
|
||||
- _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), strip[i+2]+2);
|
||||
- *bufferoffset+=strip[i+2]+2;
|
||||
- i+=strip[i+2]+2;
|
||||
+ _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), datalen+2);
|
||||
+ *bufferoffset+=datalen+2;
|
||||
} else {
|
||||
buffer[(*bufferoffset)++]=0xff;
|
||||
buffer[(*bufferoffset)++]=
|
||||
(unsigned char)(0xd0 | ((no-1)%8));
|
||||
- i+=strip[i+2]+2;
|
||||
}
|
||||
- _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), (*striplength)-i-1);
|
||||
- *bufferoffset+=(*striplength)-i-1;
|
||||
+ i += datalen + 1;
|
||||
+ /* copy remainder of strip */
|
||||
+ _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i]), *striplength - i);
|
||||
+ *bufferoffset+= *striplength - i;
|
||||
return(1);
|
||||
default:
|
||||
- i+=strip[i+2]+2;
|
||||
+ /* ignore any other marker */
|
||||
+ break;
|
||||
}
|
||||
+ i += datalen + 1;
|
||||
}
|
||||
-
|
||||
|
||||
+ /* failed to find SOS marker */
|
||||
return(0);
|
||||
}
|
||||
#endif
|
@ -1,759 +0,0 @@
|
||||
diff -Naur tiff-4.0.3.orig/contrib/dbs/xtiff/xtiff.c tiff-4.0.3/contrib/dbs/xtiff/xtiff.c
|
||||
--- tiff-4.0.3.orig/contrib/dbs/xtiff/xtiff.c 2010-06-08 14:55:15.000000000 -0400
|
||||
+++ tiff-4.0.3/contrib/dbs/xtiff/xtiff.c 2013-05-02 12:02:42.782287939 -0400
|
||||
@@ -512,9 +512,9 @@
|
||||
Arg args[1];
|
||||
|
||||
if (tfMultiPage)
|
||||
- sprintf(buffer, "%s - page %d", fileName, tfDirectory);
|
||||
+ snprintf(buffer, sizeof(buffer), "%s - page %d", fileName, tfDirectory);
|
||||
else
|
||||
- strcpy(buffer, fileName);
|
||||
+ snprintf(buffer, sizeof(buffer), "%s", fileName);
|
||||
XtSetArg(args[0], XtNlabel, buffer);
|
||||
XtSetValues(labelWidget, args, 1);
|
||||
}
|
||||
diff -Naur tiff-4.0.3.orig/libtiff/tif_codec.c tiff-4.0.3/libtiff/tif_codec.c
|
||||
--- tiff-4.0.3.orig/libtiff/tif_codec.c 2010-12-14 09:18:28.000000000 -0500
|
||||
+++ tiff-4.0.3/libtiff/tif_codec.c 2013-05-02 12:02:42.783287946 -0400
|
||||
@@ -108,7 +108,8 @@
|
||||
const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression);
|
||||
char compression_code[20];
|
||||
|
||||
- sprintf( compression_code, "%d", tif->tif_dir.td_compression );
|
||||
+ snprintf(compression_code, sizeof(compression_code), "%d",
|
||||
+ tif->tif_dir.td_compression );
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"%s compression support is not configured",
|
||||
c ? c->name : compression_code );
|
||||
diff -Naur tiff-4.0.3.orig/libtiff/tif_dirinfo.c tiff-4.0.3/libtiff/tif_dirinfo.c
|
||||
--- tiff-4.0.3.orig/libtiff/tif_dirinfo.c 2012-08-19 12:56:34.000000000 -0400
|
||||
+++ tiff-4.0.3/libtiff/tif_dirinfo.c 2013-05-02 12:02:42.784287953 -0400
|
||||
@@ -711,7 +711,7 @@
|
||||
* note that this name is a special sign to TIFFClose() and
|
||||
* _TIFFSetupFields() to free the field
|
||||
*/
|
||||
- sprintf(fld->field_name, "Tag %d", (int) tag);
|
||||
+ snprintf(fld->field_name, 32, "Tag %d", (int) tag);
|
||||
|
||||
return fld;
|
||||
}
|
||||
diff -Naur tiff-4.0.3.orig/tools/rgb2ycbcr.c tiff-4.0.3/tools/rgb2ycbcr.c
|
||||
--- tiff-4.0.3.orig/tools/rgb2ycbcr.c 2011-05-31 13:03:16.000000000 -0400
|
||||
+++ tiff-4.0.3/tools/rgb2ycbcr.c 2013-05-02 12:02:42.785287961 -0400
|
||||
@@ -332,7 +332,8 @@
|
||||
TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||
{ char buf[2048];
|
||||
char *cp = strrchr(TIFFFileName(in), '/');
|
||||
- sprintf(buf, "YCbCr conversion of %s", cp ? cp+1 : TIFFFileName(in));
|
||||
+ snprintf(buf, sizeof(buf), "YCbCr conversion of %s",
|
||||
+ cp ? cp+1 : TIFFFileName(in));
|
||||
TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, buf);
|
||||
}
|
||||
TIFFSetField(out, TIFFTAG_SOFTWARE, TIFFGetVersion());
|
||||
diff -Naur tiff-4.0.3.orig/tools/tiff2bw.c tiff-4.0.3/tools/tiff2bw.c
|
||||
--- tiff-4.0.3.orig/tools/tiff2bw.c 2010-07-08 12:10:24.000000000 -0400
|
||||
+++ tiff-4.0.3/tools/tiff2bw.c 2013-05-02 12:02:42.785287961 -0400
|
||||
@@ -205,7 +205,7 @@
|
||||
}
|
||||
}
|
||||
TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
|
||||
- sprintf(thing, "B&W version of %s", argv[optind]);
|
||||
+ snprintf(thing, sizeof(thing), "B&W version of %s", argv[optind]);
|
||||
TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, thing);
|
||||
TIFFSetField(out, TIFFTAG_SOFTWARE, "tiff2bw");
|
||||
outbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out));
|
||||
diff -Naur tiff-4.0.3.orig/tools/tiff2pdf.c tiff-4.0.3/tools/tiff2pdf.c
|
||||
--- tiff-4.0.3.orig/tools/tiff2pdf.c 2012-07-25 22:56:43.000000000 -0400
|
||||
+++ tiff-4.0.3/tools/tiff2pdf.c 2013-05-02 12:02:42.788287983 -0400
|
||||
@@ -3609,7 +3609,9 @@
|
||||
char buffer[16];
|
||||
int buflen=0;
|
||||
|
||||
- buflen=sprintf(buffer, "%%PDF-%u.%u ", t2p->pdf_majorversion&0xff, t2p->pdf_minorversion&0xff);
|
||||
+ buflen = snprintf(buffer, sizeof(buffer), "%%PDF-%u.%u ",
|
||||
+ t2p->pdf_majorversion&0xff,
|
||||
+ t2p->pdf_minorversion&0xff);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t)"\n%\342\343\317\323\n", 7);
|
||||
|
||||
@@ -3623,10 +3625,10 @@
|
||||
tsize_t t2p_write_pdf_obj_start(uint32 number, TIFF* output){
|
||||
|
||||
tsize_t written=0;
|
||||
- char buffer[16];
|
||||
+ char buffer[32];
|
||||
int buflen=0;
|
||||
|
||||
- buflen=sprintf(buffer, "%lu", (unsigned long)number);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)number);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen );
|
||||
written += t2pWriteFile(output, (tdata_t) " 0 obj\n", 7);
|
||||
|
||||
@@ -3665,13 +3667,13 @@
|
||||
written += t2pWriteFile(output, (tdata_t) "/", 1);
|
||||
for (i=0;i<namelen;i++){
|
||||
if ( ((unsigned char)name[i]) < 0x21){
|
||||
- sprintf(buffer, "#%.2X", name[i]);
|
||||
+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, 3);
|
||||
nextchar=1;
|
||||
}
|
||||
if ( ((unsigned char)name[i]) > 0x7E){
|
||||
- sprintf(buffer, "#%.2X", name[i]);
|
||||
+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, 3);
|
||||
nextchar=1;
|
||||
@@ -3679,57 +3681,57 @@
|
||||
if (nextchar==0){
|
||||
switch (name[i]){
|
||||
case 0x23:
|
||||
- sprintf(buffer, "#%.2X", name[i]);
|
||||
+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, 3);
|
||||
break;
|
||||
case 0x25:
|
||||
- sprintf(buffer, "#%.2X", name[i]);
|
||||
+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, 3);
|
||||
break;
|
||||
case 0x28:
|
||||
- sprintf(buffer, "#%.2X", name[i]);
|
||||
+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, 3);
|
||||
break;
|
||||
case 0x29:
|
||||
- sprintf(buffer, "#%.2X", name[i]);
|
||||
+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, 3);
|
||||
break;
|
||||
case 0x2F:
|
||||
- sprintf(buffer, "#%.2X", name[i]);
|
||||
+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, 3);
|
||||
break;
|
||||
case 0x3C:
|
||||
- sprintf(buffer, "#%.2X", name[i]);
|
||||
+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, 3);
|
||||
break;
|
||||
case 0x3E:
|
||||
- sprintf(buffer, "#%.2X", name[i]);
|
||||
+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, 3);
|
||||
break;
|
||||
case 0x5B:
|
||||
- sprintf(buffer, "#%.2X", name[i]);
|
||||
+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, 3);
|
||||
break;
|
||||
case 0x5D:
|
||||
- sprintf(buffer, "#%.2X", name[i]);
|
||||
+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, 3);
|
||||
break;
|
||||
case 0x7B:
|
||||
- sprintf(buffer, "#%.2X", name[i]);
|
||||
+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, 3);
|
||||
break;
|
||||
case 0x7D:
|
||||
- sprintf(buffer, "#%.2X", name[i]);
|
||||
+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, 3);
|
||||
break;
|
||||
@@ -3844,14 +3846,14 @@
|
||||
tsize_t t2p_write_pdf_stream_dict(tsize_t len, uint32 number, TIFF* output){
|
||||
|
||||
tsize_t written=0;
|
||||
- char buffer[16];
|
||||
+ char buffer[32];
|
||||
int buflen=0;
|
||||
|
||||
written += t2pWriteFile(output, (tdata_t) "/Length ", 8);
|
||||
if(len!=0){
|
||||
written += t2p_write_pdf_stream_length(len, output);
|
||||
} else {
|
||||
- buflen=sprintf(buffer, "%lu", (unsigned long)number);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)number);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6);
|
||||
}
|
||||
@@ -3892,10 +3894,10 @@
|
||||
tsize_t t2p_write_pdf_stream_length(tsize_t len, TIFF* output){
|
||||
|
||||
tsize_t written=0;
|
||||
- char buffer[16];
|
||||
+ char buffer[32];
|
||||
int buflen=0;
|
||||
|
||||
- buflen=sprintf(buffer, "%lu", (unsigned long)len);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)len);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) "\n", 1);
|
||||
|
||||
@@ -3909,7 +3911,7 @@
|
||||
tsize_t t2p_write_pdf_catalog(T2P* t2p, TIFF* output)
|
||||
{
|
||||
tsize_t written = 0;
|
||||
- char buffer[16];
|
||||
+ char buffer[32];
|
||||
int buflen = 0;
|
||||
|
||||
written += t2pWriteFile(output,
|
||||
@@ -3948,7 +3950,6 @@
|
||||
written += t2p_write_pdf_string(t2p->pdf_datetime, output);
|
||||
}
|
||||
written += t2pWriteFile(output, (tdata_t) "\n/Producer ", 11);
|
||||
- _TIFFmemset((tdata_t)buffer, 0x00, sizeof(buffer));
|
||||
snprintf(buffer, sizeof(buffer), "libtiff / tiff2pdf - %d", TIFFLIB_VERSION);
|
||||
written += t2p_write_pdf_string(buffer, output);
|
||||
written += t2pWriteFile(output, (tdata_t) "\n", 1);
|
||||
@@ -4089,7 +4090,7 @@
|
||||
{
|
||||
tsize_t written=0;
|
||||
tdir_t i=0;
|
||||
- char buffer[16];
|
||||
+ char buffer[32];
|
||||
int buflen=0;
|
||||
|
||||
int page=0;
|
||||
@@ -4097,7 +4098,7 @@
|
||||
(tdata_t) "<< \n/Type /Pages \n/Kids [ ", 26);
|
||||
page = t2p->pdf_pages+1;
|
||||
for (i=0;i<t2p->tiff_pagecount;i++){
|
||||
- buflen=sprintf(buffer, "%d", page);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%d", page);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " 0 R ", 5);
|
||||
if ( ((i+1)%8)==0 ) {
|
||||
@@ -4112,8 +4113,7 @@
|
||||
}
|
||||
}
|
||||
written += t2pWriteFile(output, (tdata_t) "] \n/Count ", 10);
|
||||
- _TIFFmemset(buffer, 0x00, 16);
|
||||
- buflen=sprintf(buffer, "%d", t2p->tiff_pagecount);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%d", t2p->tiff_pagecount);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " \n>> \n", 6);
|
||||
|
||||
@@ -4128,28 +4128,28 @@
|
||||
|
||||
unsigned int i=0;
|
||||
tsize_t written=0;
|
||||
- char buffer[16];
|
||||
+ char buffer[256];
|
||||
int buflen=0;
|
||||
|
||||
written += t2pWriteFile(output, (tdata_t) "<<\n/Type /Page \n/Parent ", 24);
|
||||
- buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_pages);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_pages);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6);
|
||||
written += t2pWriteFile(output, (tdata_t) "/MediaBox [", 11);
|
||||
- buflen=sprintf(buffer, "%.4f",t2p->pdf_mediabox.x1);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%.4f",t2p->pdf_mediabox.x1);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " ", 1);
|
||||
- buflen=sprintf(buffer, "%.4f",t2p->pdf_mediabox.y1);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%.4f",t2p->pdf_mediabox.y1);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " ", 1);
|
||||
- buflen=sprintf(buffer, "%.4f",t2p->pdf_mediabox.x2);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%.4f",t2p->pdf_mediabox.x2);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " ", 1);
|
||||
- buflen=sprintf(buffer, "%.4f",t2p->pdf_mediabox.y2);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%.4f",t2p->pdf_mediabox.y2);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) "] \n", 3);
|
||||
written += t2pWriteFile(output, (tdata_t) "/Contents ", 10);
|
||||
- buflen=sprintf(buffer, "%lu", (unsigned long)(object + 1));
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)(object + 1));
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6);
|
||||
written += t2pWriteFile(output, (tdata_t) "/Resources << \n", 15);
|
||||
@@ -4157,15 +4157,13 @@
|
||||
written += t2pWriteFile(output, (tdata_t) "/XObject <<\n", 12);
|
||||
for(i=0;i<t2p->tiff_tiles[t2p->pdf_page].tiles_tilecount;i++){
|
||||
written += t2pWriteFile(output, (tdata_t) "/Im", 3);
|
||||
- buflen = sprintf(buffer, "%u", t2p->pdf_page+1);
|
||||
+ buflen = snprintf(buffer, sizeof(buffer), "%u", t2p->pdf_page+1);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) "_", 1);
|
||||
- buflen = sprintf(buffer, "%u", i+1);
|
||||
+ buflen = snprintf(buffer, sizeof(buffer), "%u", i+1);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " ", 1);
|
||||
- buflen = sprintf(
|
||||
- buffer,
|
||||
- "%lu",
|
||||
+ buflen = snprintf(buffer, sizeof(buffer), "%lu",
|
||||
(unsigned long)(object+3+(2*i)+t2p->tiff_pages[t2p->pdf_page].page_extra));
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " 0 R ", 5);
|
||||
@@ -4177,12 +4175,10 @@
|
||||
} else {
|
||||
written += t2pWriteFile(output, (tdata_t) "/XObject <<\n", 12);
|
||||
written += t2pWriteFile(output, (tdata_t) "/Im", 3);
|
||||
- buflen = sprintf(buffer, "%u", t2p->pdf_page+1);
|
||||
+ buflen = snprintf(buffer, sizeof(buffer), "%u", t2p->pdf_page+1);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " ", 1);
|
||||
- buflen = sprintf(
|
||||
- buffer,
|
||||
- "%lu",
|
||||
+ buflen = snprintf(buffer, sizeof(buffer), "%lu",
|
||||
(unsigned long)(object+3+(2*i)+t2p->tiff_pages[t2p->pdf_page].page_extra));
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " 0 R ", 5);
|
||||
@@ -4191,9 +4187,7 @@
|
||||
if(t2p->tiff_transferfunctioncount != 0) {
|
||||
written += t2pWriteFile(output, (tdata_t) "/ExtGState <<", 13);
|
||||
t2pWriteFile(output, (tdata_t) "/GS1 ", 5);
|
||||
- buflen = sprintf(
|
||||
- buffer,
|
||||
- "%lu",
|
||||
+ buflen = snprintf(buffer, sizeof(buffer), "%lu",
|
||||
(unsigned long)(object + 3));
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " 0 R ", 5);
|
||||
@@ -4566,7 +4560,7 @@
|
||||
if(t2p->tiff_tiles[t2p->pdf_page].tiles_tilecount>0){
|
||||
for(i=0;i<t2p->tiff_tiles[t2p->pdf_page].tiles_tilecount; i++){
|
||||
box=t2p->tiff_tiles[t2p->pdf_page].tiles_tiles[i].tile_box;
|
||||
- buflen=sprintf(buffer,
|
||||
+ buflen=snprintf(buffer, sizeof(buffer),
|
||||
"q %s %.4f %.4f %.4f %.4f %.4f %.4f cm /Im%d_%ld Do Q\n",
|
||||
t2p->tiff_transferfunctioncount?"/GS1 gs ":"",
|
||||
box.mat[0],
|
||||
@@ -4581,7 +4575,7 @@
|
||||
}
|
||||
} else {
|
||||
box=t2p->pdf_imagebox;
|
||||
- buflen=sprintf(buffer,
|
||||
+ buflen=snprintf(buffer, sizeof(buffer),
|
||||
"q %s %.4f %.4f %.4f %.4f %.4f %.4f cm /Im%d Do Q\n",
|
||||
t2p->tiff_transferfunctioncount?"/GS1 gs ":"",
|
||||
box.mat[0],
|
||||
@@ -4606,59 +4600,48 @@
|
||||
TIFF* output){
|
||||
|
||||
tsize_t written=0;
|
||||
- char buffer[16];
|
||||
+ char buffer[32];
|
||||
int buflen=0;
|
||||
|
||||
written += t2p_write_pdf_stream_dict(0, t2p->pdf_xrefcount+1, output);
|
||||
written += t2pWriteFile(output,
|
||||
(tdata_t) "/Type /XObject \n/Subtype /Image \n/Name /Im",
|
||||
42);
|
||||
- buflen=sprintf(buffer, "%u", t2p->pdf_page+1);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->pdf_page+1);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
if(tile != 0){
|
||||
written += t2pWriteFile(output, (tdata_t) "_", 1);
|
||||
- buflen=sprintf(buffer, "%lu", (unsigned long)tile);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)tile);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
}
|
||||
written += t2pWriteFile(output, (tdata_t) "\n/Width ", 8);
|
||||
- _TIFFmemset((tdata_t)buffer, 0x00, 16);
|
||||
if(tile==0){
|
||||
- buflen=sprintf(buffer, "%lu", (unsigned long)t2p->tiff_width);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->tiff_width);
|
||||
} else {
|
||||
if(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)!=0){
|
||||
- buflen=sprintf(
|
||||
- buffer,
|
||||
- "%lu",
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
|
||||
(unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth);
|
||||
} else {
|
||||
- buflen=sprintf(
|
||||
- buffer,
|
||||
- "%lu",
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
|
||||
(unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth);
|
||||
}
|
||||
}
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) "\n/Height ", 9);
|
||||
- _TIFFmemset((tdata_t)buffer, 0x00, 16);
|
||||
if(tile==0){
|
||||
- buflen=sprintf(buffer, "%lu", (unsigned long)t2p->tiff_length);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->tiff_length);
|
||||
} else {
|
||||
if(t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)!=0){
|
||||
- buflen=sprintf(
|
||||
- buffer,
|
||||
- "%lu",
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
|
||||
(unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength);
|
||||
} else {
|
||||
- buflen=sprintf(
|
||||
- buffer,
|
||||
- "%lu",
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
|
||||
(unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength);
|
||||
}
|
||||
}
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) "\n/BitsPerComponent ", 19);
|
||||
- _TIFFmemset((tdata_t)buffer, 0x00, 16);
|
||||
- buflen=sprintf(buffer, "%u", t2p->tiff_bitspersample);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->tiff_bitspersample);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) "\n/ColorSpace ", 13);
|
||||
written += t2p_write_pdf_xobject_cs(t2p, output);
|
||||
@@ -4702,11 +4685,10 @@
|
||||
t2p->pdf_colorspace ^= T2P_CS_PALETTE;
|
||||
written += t2p_write_pdf_xobject_cs(t2p, output);
|
||||
t2p->pdf_colorspace |= T2P_CS_PALETTE;
|
||||
- buflen=sprintf(buffer, "%u", (0x0001 << t2p->tiff_bitspersample)-1 );
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%u", (0x0001 << t2p->tiff_bitspersample)-1 );
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " ", 1);
|
||||
- _TIFFmemset(buffer, 0x00, 16);
|
||||
- buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_palettecs );
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_palettecs );
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " 0 R ]\n", 7);
|
||||
return(written);
|
||||
@@ -4740,10 +4722,10 @@
|
||||
X_W /= Y_W;
|
||||
Z_W /= Y_W;
|
||||
Y_W = 1.0F;
|
||||
- buflen=sprintf(buffer, "[%.4f %.4f %.4f] \n", X_W, Y_W, Z_W);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "[%.4f %.4f %.4f] \n", X_W, Y_W, Z_W);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) "/Range ", 7);
|
||||
- buflen=sprintf(buffer, "[%d %d %d %d] \n",
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "[%d %d %d %d] \n",
|
||||
t2p->pdf_labrange[0],
|
||||
t2p->pdf_labrange[1],
|
||||
t2p->pdf_labrange[2],
|
||||
@@ -4759,26 +4741,26 @@
|
||||
tsize_t t2p_write_pdf_transfer(T2P* t2p, TIFF* output){
|
||||
|
||||
tsize_t written=0;
|
||||
- char buffer[16];
|
||||
+ char buffer[32];
|
||||
int buflen=0;
|
||||
|
||||
written += t2pWriteFile(output, (tdata_t) "<< /Type /ExtGState \n/TR ", 25);
|
||||
if(t2p->tiff_transferfunctioncount == 1){
|
||||
- buflen=sprintf(buffer, "%lu",
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
|
||||
(unsigned long)(t2p->pdf_xrefcount + 1));
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " 0 R ", 5);
|
||||
} else {
|
||||
written += t2pWriteFile(output, (tdata_t) "[ ", 2);
|
||||
- buflen=sprintf(buffer, "%lu",
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
|
||||
(unsigned long)(t2p->pdf_xrefcount + 1));
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " 0 R ", 5);
|
||||
- buflen=sprintf(buffer, "%lu",
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
|
||||
(unsigned long)(t2p->pdf_xrefcount + 2));
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " 0 R ", 5);
|
||||
- buflen=sprintf(buffer, "%lu",
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
|
||||
(unsigned long)(t2p->pdf_xrefcount + 3));
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " 0 R ", 5);
|
||||
@@ -4800,7 +4782,7 @@
|
||||
written += t2pWriteFile(output, (tdata_t) "/FunctionType 0 \n", 17);
|
||||
written += t2pWriteFile(output, (tdata_t) "/Domain [0.0 1.0] \n", 19);
|
||||
written += t2pWriteFile(output, (tdata_t) "/Range [0.0 1.0] \n", 18);
|
||||
- buflen=sprintf(buffer, "/Size [%u] \n", (1<<t2p->tiff_bitspersample));
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "/Size [%u] \n", (1<<t2p->tiff_bitspersample));
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) "/BitsPerSample 16 \n", 19);
|
||||
written += t2p_write_pdf_stream_dict(((tsize_t)1)<<(t2p->tiff_bitspersample+1), 0, output);
|
||||
@@ -4827,7 +4809,7 @@
|
||||
tsize_t t2p_write_pdf_xobject_calcs(T2P* t2p, TIFF* output){
|
||||
|
||||
tsize_t written=0;
|
||||
- char buffer[128];
|
||||
+ char buffer[256];
|
||||
int buflen=0;
|
||||
|
||||
float X_W=0.0;
|
||||
@@ -4895,16 +4877,16 @@
|
||||
written += t2pWriteFile(output, (tdata_t) "<< \n", 4);
|
||||
if(t2p->pdf_colorspace & T2P_CS_CALGRAY){
|
||||
written += t2pWriteFile(output, (tdata_t) "/WhitePoint ", 12);
|
||||
- buflen=sprintf(buffer, "[%.4f %.4f %.4f] \n", X_W, Y_W, Z_W);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "[%.4f %.4f %.4f] \n", X_W, Y_W, Z_W);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) "/Gamma 2.2 \n", 12);
|
||||
}
|
||||
if(t2p->pdf_colorspace & T2P_CS_CALRGB){
|
||||
written += t2pWriteFile(output, (tdata_t) "/WhitePoint ", 12);
|
||||
- buflen=sprintf(buffer, "[%.4f %.4f %.4f] \n", X_W, Y_W, Z_W);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "[%.4f %.4f %.4f] \n", X_W, Y_W, Z_W);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) "/Matrix ", 8);
|
||||
- buflen=sprintf(buffer, "[%.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f] \n",
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "[%.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f] \n",
|
||||
X_R, Y_R, Z_R,
|
||||
X_G, Y_G, Z_G,
|
||||
X_B, Y_B, Z_B);
|
||||
@@ -4923,11 +4905,11 @@
|
||||
tsize_t t2p_write_pdf_xobject_icccs(T2P* t2p, TIFF* output){
|
||||
|
||||
tsize_t written=0;
|
||||
- char buffer[16];
|
||||
+ char buffer[32];
|
||||
int buflen=0;
|
||||
|
||||
written += t2pWriteFile(output, (tdata_t) "[/ICCBased ", 11);
|
||||
- buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_icccs);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_icccs);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " 0 R] \n", 7);
|
||||
|
||||
@@ -4937,11 +4919,11 @@
|
||||
tsize_t t2p_write_pdf_xobject_icccs_dict(T2P* t2p, TIFF* output){
|
||||
|
||||
tsize_t written=0;
|
||||
- char buffer[16];
|
||||
+ char buffer[32];
|
||||
int buflen=0;
|
||||
|
||||
written += t2pWriteFile(output, (tdata_t) "/N ", 3);
|
||||
- buflen=sprintf(buffer, "%u \n", t2p->tiff_samplesperpixel);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%u \n", t2p->tiff_samplesperpixel);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) "/Alternate ", 11);
|
||||
t2p->pdf_colorspace ^= T2P_CS_ICCBASED;
|
||||
@@ -5006,7 +4988,7 @@
|
||||
tsize_t t2p_write_pdf_xobject_stream_filter(ttile_t tile, T2P* t2p, TIFF* output){
|
||||
|
||||
tsize_t written=0;
|
||||
- char buffer[16];
|
||||
+ char buffer[32];
|
||||
int buflen=0;
|
||||
|
||||
if(t2p->pdf_compression==T2P_COMPRESS_NONE){
|
||||
@@ -5021,41 +5003,33 @@
|
||||
written += t2pWriteFile(output, (tdata_t) "<< /K -1 ", 9);
|
||||
if(tile==0){
|
||||
written += t2pWriteFile(output, (tdata_t) "/Columns ", 9);
|
||||
- buflen=sprintf(buffer, "%lu",
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
|
||||
(unsigned long)t2p->tiff_width);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " /Rows ", 7);
|
||||
- buflen=sprintf(buffer, "%lu",
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
|
||||
(unsigned long)t2p->tiff_length);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
} else {
|
||||
if(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)==0){
|
||||
written += t2pWriteFile(output, (tdata_t) "/Columns ", 9);
|
||||
- buflen=sprintf(
|
||||
- buffer,
|
||||
- "%lu",
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
|
||||
(unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
} else {
|
||||
written += t2pWriteFile(output, (tdata_t) "/Columns ", 9);
|
||||
- buflen=sprintf(
|
||||
- buffer,
|
||||
- "%lu",
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
|
||||
(unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
}
|
||||
if(t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)==0){
|
||||
written += t2pWriteFile(output, (tdata_t) " /Rows ", 7);
|
||||
- buflen=sprintf(
|
||||
- buffer,
|
||||
- "%lu",
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
|
||||
(unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
} else {
|
||||
written += t2pWriteFile(output, (tdata_t) " /Rows ", 7);
|
||||
- buflen=sprintf(
|
||||
- buffer,
|
||||
- "%lu",
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
|
||||
(unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
}
|
||||
@@ -5082,21 +5056,17 @@
|
||||
if(t2p->pdf_compressionquality%100){
|
||||
written += t2pWriteFile(output, (tdata_t) "/DecodeParms ", 13);
|
||||
written += t2pWriteFile(output, (tdata_t) "<< /Predictor ", 14);
|
||||
- _TIFFmemset(buffer, 0x00, 16);
|
||||
- buflen=sprintf(buffer, "%u", t2p->pdf_compressionquality%100);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->pdf_compressionquality%100);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " /Columns ", 10);
|
||||
- _TIFFmemset(buffer, 0x00, 16);
|
||||
- buflen = sprintf(buffer, "%lu",
|
||||
+ buflen = snprintf(buffer, sizeof(buffer), "%lu",
|
||||
(unsigned long)t2p->tiff_width);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " /Colors ", 9);
|
||||
- _TIFFmemset(buffer, 0x00, 16);
|
||||
- buflen=sprintf(buffer, "%u", t2p->tiff_samplesperpixel);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->tiff_samplesperpixel);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " /BitsPerComponent ", 19);
|
||||
- _TIFFmemset(buffer, 0x00, 16);
|
||||
- buflen=sprintf(buffer, "%u", t2p->tiff_bitspersample);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->tiff_bitspersample);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) ">>\n", 3);
|
||||
}
|
||||
@@ -5116,16 +5086,16 @@
|
||||
tsize_t t2p_write_pdf_xreftable(T2P* t2p, TIFF* output){
|
||||
|
||||
tsize_t written=0;
|
||||
- char buffer[21];
|
||||
+ char buffer[64];
|
||||
int buflen=0;
|
||||
uint32 i=0;
|
||||
|
||||
written += t2pWriteFile(output, (tdata_t) "xref\n0 ", 7);
|
||||
- buflen=sprintf(buffer, "%lu", (unsigned long)(t2p->pdf_xrefcount + 1));
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)(t2p->pdf_xrefcount + 1));
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
written += t2pWriteFile(output, (tdata_t) " \n0000000000 65535 f \n", 22);
|
||||
for (i=0;i<t2p->pdf_xrefcount;i++){
|
||||
- sprintf(buffer, "%.10lu 00000 n \n",
|
||||
+ snprintf(buffer, sizeof(buffer), "%.10lu 00000 n \n",
|
||||
(unsigned long)t2p->pdf_xrefoffsets[i]);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, 20);
|
||||
}
|
||||
@@ -5149,17 +5119,14 @@
|
||||
snprintf(t2p->pdf_fileid + i, 9, "%.8X", rand());
|
||||
|
||||
written += t2pWriteFile(output, (tdata_t) "trailer\n<<\n/Size ", 17);
|
||||
- buflen = sprintf(buffer, "%lu", (unsigned long)(t2p->pdf_xrefcount+1));
|
||||
+ buflen = snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)(t2p->pdf_xrefcount+1));
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
- _TIFFmemset(buffer, 0x00, 32);
|
||||
written += t2pWriteFile(output, (tdata_t) "\n/Root ", 7);
|
||||
- buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_catalog);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_catalog);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
- _TIFFmemset(buffer, 0x00, 32);
|
||||
written += t2pWriteFile(output, (tdata_t) " 0 R \n/Info ", 12);
|
||||
- buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_info);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_info);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
- _TIFFmemset(buffer, 0x00, 32);
|
||||
written += t2pWriteFile(output, (tdata_t) " 0 R \n/ID[<", 11);
|
||||
written += t2pWriteFile(output, (tdata_t) t2p->pdf_fileid,
|
||||
sizeof(t2p->pdf_fileid) - 1);
|
||||
@@ -5167,9 +5134,8 @@
|
||||
written += t2pWriteFile(output, (tdata_t) t2p->pdf_fileid,
|
||||
sizeof(t2p->pdf_fileid) - 1);
|
||||
written += t2pWriteFile(output, (tdata_t) ">]\n>>\nstartxref\n", 16);
|
||||
- buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_startxref);
|
||||
+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_startxref);
|
||||
written += t2pWriteFile(output, (tdata_t) buffer, buflen);
|
||||
- _TIFFmemset(buffer, 0x00, 32);
|
||||
written += t2pWriteFile(output, (tdata_t) "\n%%EOF\n", 7);
|
||||
|
||||
return(written);
|
||||
diff -Naur tiff-4.0.3.orig/tools/tiff2ps.c tiff-4.0.3/tools/tiff2ps.c
|
||||
--- tiff-4.0.3.orig/tools/tiff2ps.c 2011-05-31 13:10:18.000000000 -0400
|
||||
+++ tiff-4.0.3/tools/tiff2ps.c 2013-05-02 12:02:42.789287990 -0400
|
||||
@@ -1781,8 +1781,8 @@
|
||||
imageOp = "imagemask";
|
||||
|
||||
(void)strcpy(im_x, "0");
|
||||
- (void)sprintf(im_y, "%lu", (long) h);
|
||||
- (void)sprintf(im_h, "%lu", (long) h);
|
||||
+ (void)snprintf(im_y, sizeof(im_y), "%lu", (long) h);
|
||||
+ (void)snprintf(im_h, sizeof(im_h), "%lu", (long) h);
|
||||
tile_width = w;
|
||||
tile_height = h;
|
||||
if (TIFFIsTiled(tif)) {
|
||||
@@ -1803,7 +1803,7 @@
|
||||
}
|
||||
if (tile_height < h) {
|
||||
fputs("/im_y 0 def\n", fd);
|
||||
- (void)sprintf(im_y, "%lu im_y sub", (unsigned long) h);
|
||||
+ (void)snprintf(im_y, sizeof(im_y), "%lu im_y sub", (unsigned long) h);
|
||||
}
|
||||
} else {
|
||||
repeat_count = tf_numberstrips;
|
||||
@@ -1815,7 +1815,7 @@
|
||||
fprintf(fd, "/im_h %lu def\n",
|
||||
(unsigned long) tile_height);
|
||||
(void)strcpy(im_h, "im_h");
|
||||
- (void)sprintf(im_y, "%lu im_y sub", (unsigned long) h);
|
||||
+ (void)snprintf(im_y, sizeof(im_y), "%lu im_y sub", (unsigned long) h);
|
||||
}
|
||||
}
|
||||
|
||||
diff -Naur tiff-4.0.3.orig/tools/tiffcrop.c tiff-4.0.3/tools/tiffcrop.c
|
||||
--- tiff-4.0.3.orig/tools/tiffcrop.c 2010-12-14 09:18:28.000000000 -0500
|
||||
+++ tiff-4.0.3/tools/tiffcrop.c 2013-05-02 12:02:42.791288005 -0400
|
||||
@@ -2077,7 +2077,7 @@
|
||||
return 1;
|
||||
}
|
||||
|
||||
- sprintf (filenum, "-%03d%s", findex, export_ext);
|
||||
+ snprintf(filenum, sizeof(filenum), "-%03d%s", findex, export_ext);
|
||||
filenum[14] = '\0';
|
||||
strncat (exportname, filenum, 15);
|
||||
}
|
||||
@@ -2230,8 +2230,8 @@
|
||||
|
||||
/* dump.infilename is guaranteed to be NUL termimated and have 20 bytes
|
||||
fewer than PATH_MAX */
|
||||
- memset (temp_filename, '\0', PATH_MAX + 1);
|
||||
- sprintf (temp_filename, "%s-read-%03d.%s", dump.infilename, dump_images,
|
||||
+ snprintf(temp_filename, sizeof(temp_filename), "%s-read-%03d.%s",
|
||||
+ dump.infilename, dump_images,
|
||||
(dump.format == DUMP_TEXT) ? "txt" : "raw");
|
||||
if ((dump.infile = fopen(temp_filename, dump.mode)) == NULL)
|
||||
{
|
||||
@@ -2249,8 +2249,8 @@
|
||||
|
||||
/* dump.outfilename is guaranteed to be NUL termimated and have 20 bytes
|
||||
fewer than PATH_MAX */
|
||||
- memset (temp_filename, '\0', PATH_MAX + 1);
|
||||
- sprintf (temp_filename, "%s-write-%03d.%s", dump.outfilename, dump_images,
|
||||
+ snprintf(temp_filename, sizeof(temp_filename), "%s-write-%03d.%s",
|
||||
+ dump.outfilename, dump_images,
|
||||
(dump.format == DUMP_TEXT) ? "txt" : "raw");
|
||||
if ((dump.outfile = fopen(temp_filename, dump.mode)) == NULL)
|
||||
{
|
||||
diff -Naur tiff-4.0.3.orig/tools/tiffdither.c tiff-4.0.3/tools/tiffdither.c
|
||||
--- tiff-4.0.3.orig/tools/tiffdither.c 2010-03-10 13:56:50.000000000 -0500
|
||||
+++ tiff-4.0.3/tools/tiffdither.c 2013-05-02 12:02:42.792288013 -0400
|
||||
@@ -260,7 +260,7 @@
|
||||
TIFFSetField(out, TIFFTAG_FILLORDER, fillorder);
|
||||
else
|
||||
CopyField(TIFFTAG_FILLORDER, shortv);
|
||||
- sprintf(thing, "Dithered B&W version of %s", argv[optind]);
|
||||
+ snprintf(thing, sizeof(thing), "Dithered B&W version of %s", argv[optind]);
|
||||
TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, thing);
|
||||
CopyField(TIFFTAG_PHOTOMETRIC, shortv);
|
||||
CopyField(TIFFTAG_ORIENTATION, shortv);
|
@ -1,15 +0,0 @@
|
||||
diff --git a/tools/gif2tiff.c b/tools/gif2tiff.c
|
||||
index 17f7a19..375b152 100644
|
||||
--- a/tools/gif2tiff.c
|
||||
+++ b/tools/gif2tiff.c
|
||||
@@ -333,6 +333,10 @@ readraster(void)
|
||||
int status = 1;
|
||||
|
||||
datasize = getc(infile);
|
||||
+
|
||||
+ if (datasize > 12)
|
||||
+ return 0;
|
||||
+
|
||||
clear = 1 << datasize;
|
||||
eoi = clear + 1;
|
||||
avail = clear + 2;
|
@ -1,12 +0,0 @@
|
||||
diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
|
||||
index 92a1a3d..312a946 100644
|
||||
--- a/tools/tiff2pdf.c
|
||||
+++ b/tools/tiff2pdf.c
|
||||
@@ -2462,6 +2462,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){
|
||||
TIFFFileName(input));
|
||||
t2p->t2p_error = T2P_ERR_ERROR;
|
||||
_TIFFfree(buffer);
|
||||
+ return(0);
|
||||
} else {
|
||||
buffer=samplebuffer;
|
||||
t2p->tiff_datasize *= t2p->tiff_samplesperpixel;
|
@ -1,41 +0,0 @@
|
||||
diff --git a/tools/gif2tiff.c b/tools/gif2tiff.c
|
||||
index 2731273..ca824e2 100644
|
||||
--- a/tools/gif2tiff.c
|
||||
+++ b/tools/gif2tiff.c
|
||||
@@ -280,6 +280,10 @@ readgifimage(char* mode)
|
||||
fprintf(stderr, "no colormap present for image\n");
|
||||
return (0);
|
||||
}
|
||||
+ if (width == 0 || height == 0) {
|
||||
+ fprintf(stderr, "Invalid value of width or height\n");
|
||||
+ return(0);
|
||||
+ }
|
||||
if ((raster = (unsigned char*) _TIFFmalloc(width*height+EXTRAFUDGE)) == NULL) {
|
||||
fprintf(stderr, "not enough memory for image\n");
|
||||
return (0);
|
||||
@@ -406,7 +410,11 @@ process(register int code, unsigned char** fill)
|
||||
fprintf(stderr, "bad input: code=%d is larger than clear=%d\n",code, clear);
|
||||
return 0;
|
||||
}
|
||||
- *(*fill)++ = suffix[code];
|
||||
+ if (*fill >= raster + width*height) {
|
||||
+ fprintf(stderr, "raster full before eoi code\n");
|
||||
+ return 0;
|
||||
+ }
|
||||
+ *(*fill)++ = suffix[code];
|
||||
firstchar = oldcode = code;
|
||||
return 1;
|
||||
}
|
||||
@@ -436,7 +444,11 @@ process(register int code, unsigned char** fill)
|
||||
}
|
||||
oldcode = incode;
|
||||
do {
|
||||
- *(*fill)++ = *--stackp;
|
||||
+ if (*fill >= raster + width*height) {
|
||||
+ fprintf(stderr, "raster full before eoi code\n");
|
||||
+ return 0;
|
||||
+ }
|
||||
+ *(*fill)++ = *--stackp;
|
||||
} while (stackp > stack);
|
||||
return 1;
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
diff --git a/tools/gif2tiff.c b/tools/gif2tiff.c
|
||||
index 375b152..2731273 100644
|
||||
--- a/tools/gif2tiff.c
|
||||
+++ b/tools/gif2tiff.c
|
||||
@@ -402,6 +402,10 @@ process(register int code, unsigned char** fill)
|
||||
}
|
||||
|
||||
if (oldcode == -1) {
|
||||
+ if (code >= clear) {
|
||||
+ fprintf(stderr, "bad input: code=%d is larger than clear=%d\n",code, clear);
|
||||
+ return 0;
|
||||
+ }
|
||||
*(*fill)++ = suffix[code];
|
||||
firstchar = oldcode = code;
|
||||
return 1;
|
@ -1,68 +0,0 @@
|
||||
diff --git a/libtiff/tif_getimage.c b/libtiff/tif_getimage.c
|
||||
index a85273c..5e0cf92 100644
|
||||
--- a/libtiff/tif_getimage.c
|
||||
+++ b/libtiff/tif_getimage.c
|
||||
@@ -1852,10 +1852,10 @@ DECLAREContigPutFunc(putcontig8bitYCbCr42tile)
|
||||
|
||||
(void) y;
|
||||
fromskew = (fromskew * 10) / 4;
|
||||
- if ((h & 3) == 0 && (w & 1) == 0) {
|
||||
+ if ((w & 3) == 0 && (h & 1) == 0) {
|
||||
for (; h >= 2; h -= 2) {
|
||||
x = w>>2;
|
||||
- do {
|
||||
+ while(x>0) {
|
||||
int32 Cb = pp[8];
|
||||
int32 Cr = pp[9];
|
||||
|
||||
@@ -1870,7 +1870,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr42tile)
|
||||
|
||||
cp += 4, cp1 += 4;
|
||||
pp += 10;
|
||||
- } while (--x);
|
||||
+ x--;
|
||||
+ }
|
||||
cp += incr, cp1 += incr;
|
||||
pp += fromskew;
|
||||
}
|
||||
@@ -2031,7 +2032,7 @@ DECLAREContigPutFunc(putcontig8bitYCbCr21tile)
|
||||
fromskew = (fromskew * 4) / 2;
|
||||
do {
|
||||
x = w>>1;
|
||||
- do {
|
||||
+ while(x>0) {
|
||||
int32 Cb = pp[2];
|
||||
int32 Cr = pp[3];
|
||||
|
||||
@@ -2040,7 +2041,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr21tile)
|
||||
|
||||
cp += 2;
|
||||
pp += 4;
|
||||
- } while (--x);
|
||||
+ x--;
|
||||
+ }
|
||||
|
||||
if( (w&1) != 0 )
|
||||
{
|
||||
diff --git a/libtiff/tif_next.c b/libtiff/tif_next.c
|
||||
index 524e127..a6f4577 100644
|
||||
--- a/libtiff/tif_next.c
|
||||
+++ b/libtiff/tif_next.c
|
||||
@@ -71,7 +71,7 @@ NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read");
|
||||
return (0);
|
||||
}
|
||||
- for (row = buf; occ > 0; occ -= scanline, row += scanline) {
|
||||
+ for (row = buf; cc > 0 && occ > 0; occ -= scanline, row += scanline) {
|
||||
n = *bp++, cc--;
|
||||
switch (n) {
|
||||
case LITERALROW:
|
||||
@@ -90,6 +90,8 @@ NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)
|
||||
* The scanline has a literal span that begins at some
|
||||
* offset.
|
||||
*/
|
||||
+ if( cc < 4 )
|
||||
+ goto bad;
|
||||
off = (bp[0] * 256) + bp[1];
|
||||
n = (bp[2] * 256) + bp[3];
|
||||
if (cc < 4+n || off+n > scanline)
|
@ -1,122 +0,0 @@
|
||||
Back-port upstream patch to avoid assuming quite so much about what libjpeg
|
||||
will return. Needed because libjpeg-turbo with the jpeg8 API broke the
|
||||
expectations of the previous coding.
|
||||
|
||||
|
||||
diff -Naur tiff-4.0.3.orig/test/raw_decode.c tiff-4.0.3/test/raw_decode.c
|
||||
--- tiff-4.0.3.orig/test/raw_decode.c 2012-07-06 13:05:16.000000000 -0400
|
||||
+++ tiff-4.0.3/test/raw_decode.c 2012-12-19 13:04:37.609738276 -0500
|
||||
@@ -71,33 +71,54 @@
|
||||
return 1;
|
||||
}
|
||||
|
||||
-static int check_rgb_pixel( int pixel, int red, int green, int blue, unsigned char *buffer ) {
|
||||
+static int check_rgb_pixel( int pixel,
|
||||
+ int min_red, int max_red,
|
||||
+ int min_green, int max_green,
|
||||
+ int min_blue, int max_blue,
|
||||
+ unsigned char *buffer ) {
|
||||
unsigned char *rgb = buffer + 3 * pixel;
|
||||
|
||||
- if( rgb[0] == red && rgb[1] == green && rgb[2] == blue ) {
|
||||
+ if( rgb[0] >= min_red && rgb[0] <= max_red &&
|
||||
+ rgb[1] >= min_green && rgb[1] <= max_green &&
|
||||
+ rgb[2] >= min_blue && rgb[2] <= max_blue ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
fprintf( stderr, "Pixel %d did not match expected results.\n", pixel );
|
||||
- fprintf( stderr, "Expect: %3d %3d %3d\n", red, green, blue );
|
||||
- fprintf( stderr, " Got: %3d %3d %3d\n", rgb[0], rgb[1], rgb[2] );
|
||||
+ fprintf( stderr, "Got R=%d (expected %d..%d), G=%d (expected %d..%d), B=%d (expected %d..%d)\n",
|
||||
+ rgb[0], min_red, max_red,
|
||||
+ rgb[1], min_green, max_green,
|
||||
+ rgb[2], min_blue, max_blue );
|
||||
return 1;
|
||||
}
|
||||
|
||||
-static int check_rgba_pixel( int pixel, int red, int green, int blue, int alpha, uint32 *buffer ) {
|
||||
+static int check_rgba_pixel( int pixel,
|
||||
+ int min_red, int max_red,
|
||||
+ int min_green, int max_green,
|
||||
+ int min_blue, int max_blue,
|
||||
+ int min_alpha, int max_alpha,
|
||||
+ uint32 *buffer ) {
|
||||
/* RGBA images are upside down - adjust for normal ordering */
|
||||
int adjusted_pixel = pixel % 128 + (127 - (pixel/128)) * 128;
|
||||
uint32 rgba = buffer[adjusted_pixel];
|
||||
|
||||
- if( TIFFGetR(rgba) == (uint32) red && TIFFGetG(rgba) == (uint32) green &&
|
||||
- TIFFGetB(rgba) == (uint32) blue && TIFFGetA(rgba) == (uint32) alpha ) {
|
||||
+ if( TIFFGetR(rgba) >= (uint32) min_red &&
|
||||
+ TIFFGetR(rgba) <= (uint32) max_red &&
|
||||
+ TIFFGetG(rgba) >= (uint32) min_green &&
|
||||
+ TIFFGetG(rgba) <= (uint32) max_green &&
|
||||
+ TIFFGetB(rgba) >= (uint32) min_blue &&
|
||||
+ TIFFGetB(rgba) <= (uint32) max_blue &&
|
||||
+ TIFFGetA(rgba) >= (uint32) min_alpha &&
|
||||
+ TIFFGetA(rgba) <= (uint32) max_alpha ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
fprintf( stderr, "Pixel %d did not match expected results.\n", pixel );
|
||||
- fprintf( stderr, "Expect: %3d %3d %3d %3d\n", red, green, blue, alpha );
|
||||
- fprintf( stderr, " Got: %3d %3d %3d %3d\n",
|
||||
- TIFFGetR(rgba), TIFFGetG(rgba), TIFFGetB(rgba), TIFFGetA(rgba) );
|
||||
+ fprintf( stderr, "Got R=%d (expected %d..%d), G=%d (expected %d..%d), B=%d (expected %d..%d), A=%d (expected %d..%d)\n",
|
||||
+ TIFFGetR(rgba), min_red, max_red,
|
||||
+ TIFFGetG(rgba), min_green, max_green,
|
||||
+ TIFFGetB(rgba), min_blue, max_blue,
|
||||
+ TIFFGetA(rgba), min_alpha, max_alpha );
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -191,15 +212,17 @@
|
||||
return 1;
|
||||
}
|
||||
|
||||
-#if JPEG_LIB_VERSION >= 70
|
||||
- pixel_status |= check_rgb_pixel( 0, 18, 0, 41, buffer );
|
||||
- pixel_status |= check_rgb_pixel( 64, 0, 0, 0, buffer );
|
||||
- pixel_status |= check_rgb_pixel( 512, 5, 34, 196, buffer );
|
||||
-#else
|
||||
- pixel_status |= check_rgb_pixel( 0, 15, 0, 18, buffer );
|
||||
- pixel_status |= check_rgb_pixel( 64, 0, 0, 2, buffer );
|
||||
- pixel_status |= check_rgb_pixel( 512, 6, 36, 182, buffer );
|
||||
-#endif
|
||||
+ /*
|
||||
+ * JPEG decoding is inherently inexact, so we can't test for exact
|
||||
+ * pixel values. (Well, if we knew exactly which libjpeg version
|
||||
+ * we were using, and with what settings, we could expect specific
|
||||
+ * values ... but it's not worth the trouble to keep track of.)
|
||||
+ * Hence, use ranges of expected values. The ranges may need to be
|
||||
+ * widened over time as more versions of libjpeg appear.
|
||||
+ */
|
||||
+ pixel_status |= check_rgb_pixel( 0, 15, 18, 0, 0, 18, 41, buffer );
|
||||
+ pixel_status |= check_rgb_pixel( 64, 0, 0, 0, 0, 0, 2, buffer );
|
||||
+ pixel_status |= check_rgb_pixel( 512, 5, 6, 34, 36, 182, 196, buffer );
|
||||
|
||||
free( buffer );
|
||||
|
||||
@@ -224,15 +247,12 @@
|
||||
* accomplish it from the YCbCr subsampled buffer ourselves in which
|
||||
* case the results may be subtly different but similar.
|
||||
*/
|
||||
-#if JPEG_LIB_VERSION >= 70
|
||||
- pixel_status |= check_rgba_pixel( 0, 18, 0, 41, 255, rgba_buffer );
|
||||
- pixel_status |= check_rgba_pixel( 64, 0, 0, 0, 255, rgba_buffer );
|
||||
- pixel_status |= check_rgba_pixel( 512, 5, 34, 196, 255, rgba_buffer );
|
||||
-#else
|
||||
- pixel_status |= check_rgba_pixel( 0, 15, 0, 18, 255, rgba_buffer );
|
||||
- pixel_status |= check_rgba_pixel( 64, 0, 0, 2, 255, rgba_buffer );
|
||||
- pixel_status |= check_rgba_pixel( 512, 6, 36, 182, 255, rgba_buffer );
|
||||
-#endif
|
||||
+ pixel_status |= check_rgba_pixel( 0, 15, 18, 0, 0, 18, 41, 255, 255,
|
||||
+ rgba_buffer );
|
||||
+ pixel_status |= check_rgba_pixel( 64, 0, 0, 0, 0, 0, 2, 255, 255,
|
||||
+ rgba_buffer );
|
||||
+ pixel_status |= check_rgba_pixel( 512, 5, 6, 34, 36, 182, 196, 255, 255,
|
||||
+ rgba_buffer );
|
||||
|
||||
free( rgba_buffer );
|
||||
TIFFClose(tif);
|
@ -1,119 +0,0 @@
|
||||
diff --git a/man/tiff2ps.1 b/man/tiff2ps.1
|
||||
index c3a9bac..a826ad7 100644
|
||||
--- a/man/tiff2ps.1
|
||||
+++ b/man/tiff2ps.1
|
||||
@@ -100,6 +100,9 @@ Generate \*(Ps Level 2.
|
||||
Generate \*(Ps Level 3. It basically allows one to use the /flateDecode
|
||||
filter for ZIP compressed TIFF images.
|
||||
.TP
|
||||
+.B \-8
|
||||
+Disable use of ASCII85 encoding with PostScript Level 2/3
|
||||
+.TP
|
||||
.B \-a
|
||||
Generate output for all IFDs (pages) in the input file.
|
||||
.TP
|
||||
@@ -123,6 +126,9 @@ directory to the specified directory number.
|
||||
This option is useful for selecting individual pages in a
|
||||
multi-page (e.g. facsimile) file.
|
||||
.TP
|
||||
+.B \-D
|
||||
+Enable duplex printing (two pages per sheet of paper)
|
||||
+.TP
|
||||
.B \-e
|
||||
Force the generation of Encapsulated \*(Ps (implies
|
||||
.BR \-z ).
|
||||
@@ -185,6 +191,10 @@ like which are hidden using the
|
||||
.I SubIFD
|
||||
tag.
|
||||
.TP
|
||||
+.B \-O
|
||||
+Write PostScript to specified file instead of standard output
|
||||
+Set the initial
|
||||
+.TP
|
||||
.B \-p
|
||||
Force the generation of (non-Encapsulated) \*(Ps.
|
||||
.TP
|
||||
@@ -188,6 +188,9 @@ Set the initial
|
||||
.B \-p
|
||||
Force the generation of (non-Encapsulated) \*(Ps.
|
||||
.TP
|
||||
+.B \-P
|
||||
+Set optional PageOrientation DSC comment to Landscape or Portrait.
|
||||
+.TP
|
||||
.B \-r 90|180|270|auto
|
||||
Rotate image by 90, 180, 270 degrees or auto. Auto picks the best
|
||||
fit for the image on the specified paper size (eg portrait
|
||||
@@ -197,6 +207,12 @@ counterclockwise. Auto rotates 90 degrees ccw to produce landscape.
|
||||
.B \-s
|
||||
Generate output for a single IFD (page) in the input file.
|
||||
.TP
|
||||
+.B \-t
|
||||
+Specify the document title string
|
||||
+.TP
|
||||
+.B \-T
|
||||
+Print pages for top edge binding
|
||||
+.TP
|
||||
.B \-w
|
||||
Specify the horizontal size of the printed area (in inches).
|
||||
.TP
|
||||
diff --git a/man/tiffcp.1 b/man/tiffcp.1
|
||||
index 5fdcc47..bf50130 100644
|
||||
--- a/man/tiffcp.1
|
||||
+++ b/man/tiffcp.1
|
||||
@@ -60,6 +60,9 @@ in a file, but it is explicitly intended to not alter or convert
|
||||
the image data content in any way.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
+.BI \-a
|
||||
+Append to an existing output file instead of overwriting it
|
||||
+.TP
|
||||
.BI \-b " image"
|
||||
subtract the following monochrome image from all others
|
||||
processed. This can be used to remove a noise bias
|
||||
@@ -179,6 +182,9 @@ overwritten and not when it is appended to.
|
||||
.B \-M
|
||||
Suppress the use of memory-mapped files when reading images.
|
||||
.TP
|
||||
+.BI \-o " offset"
|
||||
+Set initial directory offset
|
||||
+.TP
|
||||
.B \-p
|
||||
Specify the planar configuration to use in writing image data
|
||||
that has one 8-bit sample per pixel.
|
||||
@@ -228,6 +228,9 @@ appear in a tile.
|
||||
.B \-x
|
||||
Force the output file to be written with PAGENUMBER value in sequence.
|
||||
.TP
|
||||
+.B \-8
|
||||
+Write BigTIFF instead of classic TIFF format.
|
||||
+.TP
|
||||
.BI \-,= character
|
||||
substitute
|
||||
.I character
|
||||
diff --git a/tools/tiffcp.c b/tools/tiffcp.c
|
||||
index 0f81b19..8c696db 100644
|
||||
--- a/tools/tiffcp.c
|
||||
+++ b/tools/tiffcp.c
|
||||
@@ -409,6 +409,10 @@ char* stuff[] = {
|
||||
" -s write output in strips",
|
||||
" -t write output in tiles",
|
||||
" -8 write BigTIFF instead of default ClassicTIFF",
|
||||
+" -B write big-endian instead of native byte order",
|
||||
+" -L write little-endian instead of native byte order",
|
||||
+" -M disable use of memory-mapped files",
|
||||
+" -C disable strip chopping",
|
||||
" -i ignore read errors",
|
||||
" -b file[,#] bias (dark) monochrome image to be subtracted from all others",
|
||||
" -,=% use % rather than , to separate image #'s (per Note below)",
|
||||
diff --git a/man/tiff2ps.1 b/man/tiff2ps.1
|
||||
index b4a304a..0d672b0 100644
|
||||
--- a/man/tiff2ps.1
|
||||
+++ b/man/tiff2ps.1
|
||||
@@ -149,6 +149,7 @@ be split in several pages. Options
|
||||
and
|
||||
.B \-W
|
||||
are mutually exclusive.
|
||||
+.TP
|
||||
.B \-i
|
||||
Enable/disable pixel interpolation. This option requires a
|
||||
single numeric value: zero to disable pixel interpolation and
|
@ -1,20 +0,0 @@
|
||||
Back-patch upstream patch of 2012-12-12 ("Fix TIFF_VARIABLE/TIFF_VARIABLE2
|
||||
confusion in TIFFPrintDirectory").
|
||||
|
||||
|
||||
diff -Naur tiff-4.0.3.orig/libtiff/tif_print.c tiff-4.0.3/libtiff/tif_print.c
|
||||
--- tiff-4.0.3.orig/libtiff/tif_print.c 2012-08-19 12:56:35.000000000 -0400
|
||||
+++ tiff-4.0.3/libtiff/tif_print.c 2012-12-12 16:53:05.355927641 -0500
|
||||
@@ -582,10 +582,10 @@
|
||||
continue;
|
||||
|
||||
if(fip->field_passcount) {
|
||||
- if (fip->field_readcount == TIFF_VARIABLE ) {
|
||||
+ if (fip->field_readcount == TIFF_VARIABLE2 ) {
|
||||
if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1)
|
||||
continue;
|
||||
- } else if (fip->field_readcount == TIFF_VARIABLE2 ) {
|
||||
+ } else if (fip->field_readcount == TIFF_VARIABLE ) {
|
||||
uint16 small_value_count;
|
||||
if(TIFFGetField(tif, tag, &small_value_count, &raw_data) != 1)
|
||||
continue;
|
55
libtiff.spec
55
libtiff.spec
@ -1,27 +1,15 @@
|
||||
Summary: Library of functions for manipulating TIFF format image files
|
||||
Name: libtiff
|
||||
Version: 4.0.3
|
||||
Release: 21%{?dist}
|
||||
License: libtiff
|
||||
Group: System Environment/Libraries
|
||||
URL: http://www.remotesensing.org/libtiff/
|
||||
Summary: Library of functions for manipulating TIFF format image files
|
||||
Name: libtiff
|
||||
Version: 4.0.4beta
|
||||
Release: 1%{?dist}
|
||||
License: libtiff
|
||||
Group: System Environment/Libraries
|
||||
URL: http://www.remotesensing.org/libtiff/
|
||||
|
||||
Source: ftp://ftp.remotesensing.org/pub/libtiff/tiff-%{version}.tar.gz
|
||||
Source: ftp://ftp.remotesensing.org/pub/libtiff/tiff-%{version}.tar.gz
|
||||
|
||||
Patch0: libtiff-am-version.patch
|
||||
Patch1: libtiff-CVE-2012-4447.patch
|
||||
Patch2: libtiff-CVE-2012-4564.patch
|
||||
Patch3: libtiff-printdir-width.patch
|
||||
Patch4: libtiff-jpeg-test.patch
|
||||
Patch5: libtiff-CVE-2013-1960.patch
|
||||
Patch6: libtiff-CVE-2013-1961.patch
|
||||
Patch7: libtiff-manpage-update.patch
|
||||
Patch8: libtiff-CVE-2013-4231.patch
|
||||
Patch9: libtiff-CVE-2013-4232.patch
|
||||
Patch10: libtiff-CVE-2013-4244.patch
|
||||
Patch11: libtiff-make-check.patch
|
||||
Patch12: libtiff-CVE-2013-4243.patch
|
||||
Patch13: libtiff-CVE-2014-9655.patch
|
||||
Patch0: libtiff-am-version.patch
|
||||
Patch1: libtiff-make-check.patch
|
||||
|
||||
BuildRequires: zlib-devel libjpeg-devel jbigkit-devel
|
||||
BuildRequires: libtool automake autoconf pkgconfig
|
||||
@ -36,10 +24,10 @@ The libtiff package should be installed if you need to manipulate TIFF
|
||||
format image files.
|
||||
|
||||
%package devel
|
||||
Summary: Development tools for programs which will use the libtiff library
|
||||
Group: Development/Libraries
|
||||
Requires: %{name}%{?_isa} = %{version}-%{release}
|
||||
Requires: pkgconfig%{?_isa}
|
||||
Summary: Development tools for programs which will use the libtiff library
|
||||
Group: Development/Libraries
|
||||
Requires: %{name}%{?_isa} = %{version}-%{release}
|
||||
Requires: pkgconfig%{?_isa}
|
||||
|
||||
%description devel
|
||||
This package contains the header files and documentation necessary for
|
||||
@ -74,18 +62,6 @@ image files using the libtiff library.
|
||||
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
%patch4 -p1
|
||||
%patch5 -p1
|
||||
%patch6 -p1
|
||||
%patch7 -p1
|
||||
%patch8 -p1
|
||||
%patch9 -p1
|
||||
%patch10 -p1
|
||||
%patch11 -p1
|
||||
%patch12 -p1
|
||||
%patch13 -p1
|
||||
|
||||
# Use build system's libtool.m4, not the one in the package.
|
||||
rm -f libtool.m4
|
||||
@ -191,6 +167,9 @@ find html -name 'Makefile*' | xargs rm
|
||||
%{_mandir}/man1/*
|
||||
|
||||
%changelog
|
||||
* Fri Jun 19 2015 Petr Hracek <phracek@redhat.com> - 4.0.4beta-1
|
||||
- New upstream version libtiff-4.0.4beta (#1186219)
|
||||
|
||||
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.0.3-21
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user