changeset 26149:242aa7b2c783

Silence unnecessary warnings about security-format (bug #55046). * Table.cc, sub2ind.cc, syscalls.cc, symbfact.cc, ov-java.cc, oct-parse.yy, pt-eval.cc: Supply a format string of "%s" when calling error() or warning() and a single string to print.
author Rik <rik@octave.org>
date Thu, 29 Nov 2018 12:15:25 -0800
parents 8c72f0345ee8
children 46757ec0bac2
files libgui/graphics/Table.cc libinterp/corefcn/sub2ind.cc libinterp/corefcn/syscalls.cc libinterp/dldfcn/symbfact.cc libinterp/octave-value/ov-java.cc libinterp/parse-tree/oct-parse.yy libinterp/parse-tree/pt-eval.cc
diffstat 7 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/graphics/Table.cc	Thu Nov 29 12:54:15 2018 +0100
+++ b/libgui/graphics/Table.cc	Thu Nov 29 12:15:25 2018 -0800
@@ -309,7 +309,7 @@
         warn_string << "Unknown conversion for datatype " << val.class_name ()
                     << " to " << format
                     << " for value " << val.string_value (true);
-        warning (warn_string.str ().c_str ());
+        warning ("%s", warn_string.str ().c_str ());
 
         text = Utils::fromStdString (val.string_value (true));
       }
@@ -551,7 +551,7 @@
                                    cellEditCallbackEventObject);
       }
     else if (error.string_value ().length () > 0)
-      warning (error.string_value ().c_str ());
+      warning ("%s", error.string_value ().c_str ());
   }
 
   void
--- a/libinterp/corefcn/sub2ind.cc	Thu Nov 29 12:54:15 2018 +0100
+++ b/libinterp/corefcn/sub2ind.cc	Thu Nov 29 12:15:25 2018 -0800
@@ -131,7 +131,7 @@
           e.set_pos_if_unset (nargin-1, j+1);
           e.set_var ();
           std::string msg = e.message ();
-          error_with_id (e.err_id (), msg.c_str ());
+          error_with_id (e.err_id (), "%s", msg.c_str ());
         }
     }
 
--- a/libinterp/corefcn/syscalls.cc	Thu Nov 29 12:54:15 2018 +0100
+++ b/libinterp/corefcn/syscalls.cc	Thu Nov 29 12:15:25 2018 -0800
@@ -290,7 +290,7 @@
   pid = octave::sys::popen2 (exec_file, arg_list, sync_mode, filedesc, msg);
 
   if (pid < 0)
-    error (msg.c_str ());
+    error ("%s", msg.c_str ());
 
   FILE *ifile = fdopen (filedesc[1], "r");
   FILE *ofile = fdopen (filedesc[0], "w");
--- a/libinterp/dldfcn/symbfact.cc	Thu Nov 29 12:54:15 2018 +0100
+++ b/libinterp/dldfcn/symbfact.cc	Thu Nov 29 12:15:25 2018 -0800
@@ -377,7 +377,7 @@
   CHOLMOD_NAME(finish) (cm);
 
   if (! err_msg.empty ())
-    error (err_msg.c_str ());
+    error ("%s", err_msg.c_str ());
 
   return retval;
 
--- a/libinterp/octave-value/ov-java.cc	Thu Nov 29 12:54:15 2018 +0100
+++ b/libinterp/octave-value/ov-java.cc	Thu Nov 29 12:15:25 2018 -0800
@@ -1938,7 +1938,7 @@
         }
       catch (std::string msg)
         {
-          error (msg.c_str ());
+          error ("%s", msg.c_str ());
         }
 
       octave_set_default_fpucw ();
--- a/libinterp/parse-tree/oct-parse.yy	Thu Nov 29 12:54:15 2018 +0100
+++ b/libinterp/parse-tree/oct-parse.yy	Thu Nov 29 12:15:25 2018 -0800
@@ -5685,7 +5685,7 @@
     // Print error message again, which was lost because of the stderr buffer
     // Note: this keeps error_state and last_error_stack intact
     message_with_id ("error", last_error_id ().c_str (),
-                     last_error_message ().c_str ());
+                     "%s", last_error_message ().c_str ());
 }
 
 static void
--- a/libinterp/parse-tree/pt-eval.cc	Thu Nov 29 12:54:15 2018 +0100
+++ b/libinterp/parse-tree/pt-eval.cc	Thu Nov 29 12:15:25 2018 -0800
@@ -2720,7 +2720,7 @@
           {
             e.set_var (lhs->name ());
             std::string msg = e.message ();
-            error_with_id (e.err_id (), msg.c_str ());
+            error_with_id (e.err_id (), "%s", msg.c_str ());
           }
       }
 
@@ -3485,7 +3485,7 @@
 
     std::string msg = e.message () + extra_message;
 
-    error_with_id (e.err_id (), msg.c_str ());
+    error_with_id (e.err_id (), "%s", msg.c_str ());
   }
 
   void