AWARE [SYSTEMS]
AWare Systems, , Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
August 2009

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
Archive maintained by AWare Systems



New Datamatrix section



Valid HTML 4.01!



Thread

2009.08.30 11:50 "string format errors", by Oden Eriksson
2009.08.30 16:25 "Re: string format errors", by Bob Friesenhahn
2009.08.30 16:41 "Re: string format errors", by Oden Eriksson
2009.08.30 17:41 "Re: string format errors", by Bob Friesenhahn

2009.08.30 11:50 "string format errors", by Oden Eriksson

Hello,

Attached is a patch to fix build with gcc when using the "-Wformat -
Werror=format-security" flags. It applies to 3.9.1

Cheers.
-- 
Regards // Oden Eriksson

diff -Naurp tiff-3.9.1/contrib/iptcutil/iptcutil.c tiff-3.9.1.oden/contrib/iptcutil/iptcutil.c
--- tiff-3.9.1/contrib/iptcutil/iptcutil.c	2004-09-21 15:34:39.000000000 +0200
+++ tiff-3.9.1.oden/contrib/iptcutil/iptcutil.c	2009-08-30 12:24:45.000000000 +0200
@@ -385,7 +385,7 @@ int main(int argc, char *argv[])
 
   if( argc < 2 )
     {
-      printf(usage);
+      printf("%s\n", usage);
 	    return 1;
     }
 
@@ -444,7 +444,7 @@ int main(int argc, char *argv[])
       }
     else
       {
-        printf(usage);
+        printf("%s\n", usage);
 	      return 1;
       }
   }
diff -Naurp tiff-3.9.1/libtiff/tif_getimage.c tiff-3.9.1.oden/libtiff/tif_getimage.c
--- tiff-3.9.1/libtiff/tif_getimage.c	2008-12-21 22:23:41.000000000 +0100
+++ tiff-3.9.1.oden/libtiff/tif_getimage.c	2009-08-30 12:24:45.000000000 +0200
@@ -481,7 +481,7 @@ TIFFReadRGBAImageOriented(TIFF* tif,
 			rwidth, img.height);
 		TIFFRGBAImageEnd(&img);
 	} else {
-		TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), emsg);
+		TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", emsg);
 		ok = 0;
     }
     return (ok);
@@ -2555,7 +2555,7 @@ TIFFReadRGBAStrip(TIFF* tif, uint32 row,
         
 	TIFFRGBAImageEnd(&img);
     } else {
-		TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), emsg);
+		TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", emsg);
 		ok = 0;
     }
     
@@ -2607,7 +2607,7 @@ TIFFReadRGBATile(TIFF* tif, uint32 col, 
     
     if (!TIFFRGBAImageOK(tif, emsg) 
 	|| !TIFFRGBAImageBegin(&img, tif, 0, emsg)) {
-	    TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), emsg);
+	    TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", emsg);
 	    return( 0 );
     }
 
diff -Naurp tiff-3.9.1/libtiff/tif_jpeg.c tiff-3.9.1.oden/libtiff/tif_jpeg.c
--- tiff-3.9.1/libtiff/tif_jpeg.c	2008-12-21 22:23:41.000000000 +0100
+++ tiff-3.9.1.oden/libtiff/tif_jpeg.c	2009-08-30 12:24:45.000000000 +0200
@@ -226,7 +226,7 @@ TIFFjpeg_error_exit(j_common_ptr cinfo)
 	char buffer[JMSG_LENGTH_MAX];
 
 	(*cinfo->err->format_message) (cinfo, buffer);
-	TIFFErrorExt(sp->tif->tif_clientdata, "JPEGLib", buffer);		/* display the error message */
+	TIFFErrorExt(sp->tif->tif_clientdata, "JPEGLib", "%s", buffer);		/* display the error message */
 	jpeg_abort(cinfo);			/* clean up libjpeg state */
 	LONGJMP(sp->exit_jmpbuf, 1);		/* return to libtiff caller */
 }
@@ -242,7 +242,7 @@ TIFFjpeg_output_message(j_common_ptr cin
 	char buffer[JMSG_LENGTH_MAX];
 
 	(*cinfo->err->format_message) (cinfo, buffer);
-	TIFFWarningExt(((JPEGState *) cinfo)->tif->tif_clientdata, "JPEGLib", buffer);
+	TIFFWarningExt(((JPEGState *) cinfo)->tif->tif_clientdata, "JPEGLib", "%s", buffer);
 }
 
 /*
diff -Naurp tiff-3.9.1/libtiff/tif_ojpeg.c tiff-3.9.1.oden/libtiff/tif_ojpeg.c
--- tiff-3.9.1/libtiff/tif_ojpeg.c	2009-08-21 00:31:00.000000000 +0200
+++ tiff-3.9.1.oden/libtiff/tif_ojpeg.c	2009-08-30 12:24:45.000000000 +0200
@@ -2359,7 +2359,7 @@ OJPEGLibjpegJpegErrorMgrOutputMessage(jp
 {
 	char buffer[JMSG_LENGTH_MAX];
 	(*cinfo->err->format_message)(cinfo,buffer);
-	TIFFWarningExt(((TIFF*)(cinfo->client_data))->tif_clientdata,"LibJpeg",buffer);
+	TIFFWarningExt(((TIFF*)(cinfo->client_data))->tif_clientdata,"LibJpeg", "%s", buffer);
 }
 
 static void
@@ -2367,7 +2367,7 @@ OJPEGLibjpegJpegErrorMgrErrorExit(jpeg_c
 {
 	char buffer[JMSG_LENGTH_MAX];
 	(*cinfo->err->format_message)(cinfo,buffer);
-	TIFFErrorExt(((TIFF*)(cinfo->client_data))->tif_clientdata,"LibJpeg",buffer);
+	TIFFErrorExt(((TIFF*)(cinfo->client_data))->tif_clientdata,"LibJpeg", "%s", buffer);
 	jpeg_encap_unwind((TIFF*)(cinfo->client_data));
 }
 
diff -Naurp tiff-3.9.1/tools/tiffcrop.c tiff-3.9.1.oden/tools/tiffcrop.c
--- tiff-3.9.1/tools/tiffcrop.c	2009-08-21 00:31:00.000000000 +0200
+++ tiff-3.9.1.oden/tools/tiffcrop.c	2009-08-30 12:24:46.000000000 +0200
@@ -1976,7 +1976,7 @@ main(int argc, char* argv[])
                   (dump.format == DUMP_TEXT) ? "txt" : "raw");
           if ((dump.infile = fopen(temp_filename, dump.mode)) == NULL)
             {
-	    TIFFError ("Unable to open dump file %s for writing", temp_filename);
+	    TIFFError ("Unable to open dump file %s for writing", "%s", temp_filename);
 	    exit (-1);
             }
           dump_info(dump.infile, dump.format, "Reading image","%d from %s", 
@@ -1992,7 +1992,7 @@ main(int argc, char* argv[])
                   (dump.format == DUMP_TEXT) ? "txt" : "raw");
           if ((dump.outfile = fopen(temp_filename, dump.mode)) == NULL)
             {
-	    TIFFError ("Unable to open dump file %s for writing", temp_filename);
+	    TIFFError ("Unable to open dump file %s for writing", "%s", temp_filename);
 	    exit (-1);
             }
           dump_info(dump.outfile, dump.format, "Writing image","%d from %s", 
diff -Naurp tiff-3.9.1/tools/tiffgt.c tiff-3.9.1.oden/tools/tiffgt.c
--- tiff-3.9.1/tools/tiffgt.c	2006-03-23 15:54:02.000000000 +0100
+++ tiff-3.9.1.oden/tools/tiffgt.c	2009-08-30 12:24:46.000000000 +0200
@@ -204,7 +204,7 @@ initImage(void)
         if (photo != (uint16) -1)
                 TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photo);
         if (!TIFFRGBAImageBegin(&img, tif, stoponerr, title)) {
-                TIFFError(filelist[fileindex], title);
+                TIFFError(filelist[fileindex], "%s", title);
                 TIFFClose(tif);
                 tif = NULL;
                 return -1;