string format errors

View: New views
4 Messages — Rating Filter:   Alert me  

string format errors

by Oden Eriksson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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


[tiff-3.8.2-format_not_a_string_literal_and_no_format_arguments.diff]

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;


_______________________________________________
Tiff mailing list: Tiff@...
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/

Re: string format errors

by Bob Friesenhahn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, 30 Aug 2009, Oden Eriksson wrote:

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

Those warnings were bothering me as well.  I have applied your fixes
to the branch-3-9 CVS branch.  Are you able to provide a similar patch
for tiff-4.0.0beta4?

Bob
--
Bob Friesenhahn
bfriesen@..., http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
_______________________________________________
Tiff mailing list: Tiff@...
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/

Re: string format errors

by Oden Eriksson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

söndagen den 30 augusti 2009 18.25.23 skrev  Bob Friesenhahn:
> On Sun, 30 Aug 2009, Oden Eriksson wrote:
> > Attached is a patch to fix build with gcc when using the "-Wformat -
> > Werror=format-security" flags. It applies to 3.9.1
>
> Those warnings were bothering me as well.  I have applied your fixes
> to the branch-3-9 CVS branch.  Are you able to provide a similar patch
> for tiff-4.0.0beta4?

Most issues seems fixed in 4.0.0beta4, a patch is applied.

--
Regards // Oden Eriksson

[tiff-4.0.0beta4-format_not_a_string_literal_and_no_format_arguments.diff]

diff -Naurp tiff-4.0.0beta4/tools/tiffcrop.c tiff-4.0.0beta4.oden/tools/tiffcrop.c
--- tiff-4.0.0beta4/tools/tiffcrop.c 2009-02-14 20:06:15.000000000 +0100
+++ tiff-4.0.0beta4.oden/tools/tiffcrop.c 2009-08-30 18:38:06.000000000 +0200
@@ -1981,7 +1981,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",
@@ -1997,7 +1997,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-4.0.0beta4/tools/tiffgt.c tiff-4.0.0beta4.oden/tools/tiffgt.c
--- tiff-4.0.0beta4/tools/tiffgt.c 2006-03-24 15:59:55.000000000 +0100
+++ tiff-4.0.0beta4.oden/tools/tiffgt.c 2009-08-30 18:38:06.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;


_______________________________________________
Tiff mailing list: Tiff@...
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/

Re: string format errors

by Bob Friesenhahn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, 30 Aug 2009, Oden Eriksson wrote:

> söndagen den 30 augusti 2009 18.25.23 skrev  Bob Friesenhahn:
>> On Sun, 30 Aug 2009, Oden Eriksson wrote:
>>> Attached is a patch to fix build with gcc when using the "-Wformat -
>>> Werror=format-security" flags. It applies to 3.9.1
>>
>> Those warnings were bothering me as well.  I have applied your fixes
>> to the branch-3-9 CVS branch.  Are you able to provide a similar patch
>> for tiff-4.0.0beta4?
>
> Most issues seems fixed in 4.0.0beta4, a patch is applied.
Your patch is applied.  Thank you very much.

Bob
--
Bob Friesenhahn
bfriesen@..., http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
_______________________________________________
Tiff mailing list: Tiff@...
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/