swig / swig

SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages.
http://www.swig.org
Other
5.75k stars 1.23k forks source link

octave 5.1 landed... #1491

Closed dirteat closed 5 years ago

dirteat commented 5 years ago

Our current swig version produces some issues (spotted by compiling plplot). I can give more details if needed. Thanks.

/rpmbuild/BUILD/plplot-5.14.0/build/bindings/octave/plplot_octaveOCTAVE_wrap.cxx
/home/iurt/rpmbuild/BUILD/plplot-5.14.0/build/bindings/octave/plplot_octaveOCTAVE_wrap.cxx: In function 'octave_value SWIG_Error(int, const char*)':
/home/iurt/rpmbuild/BUILD/plplot-5.14.0/build/bindings/octave/plplot_octaveOCTAVE_wrap.cxx:921:18: error: format not a string literal and no format arguments [-Werror=format-security]
   error(r.c_str());
                  ^
/home/iurt/rpmbuild/BUILD/plplot-5.14.0/build/bindings/octave/plplot_octaveOCTAVE_wrap.cxx: In member function 'virtual octave_value octave_swig_type::map(octave_base_value::unary_mapper_t) const':
/home/iurt/rpmbuild/BUILD/plplot-5.14.0/build/bindings/octave/plplot_octaveOCTAVE_wrap.cxx:1710:66: error: format not a string literal and no format arguments [-Werror=format-security]
         error((opname + std::string(" method not found")).c_str());
dirteat commented 5 years ago

It is a format security issue. I have fixed it with:

--- swig-3.0.12/Lib/octave/octrun.swg.orig      2019-03-06 09:57:01.867281610 +0100
+++ swig-3.0.12/Lib/octave/octrun.swg   2019-03-06 09:57:23.547590590 +0100
@@ -51,7 +51,7 @@
   octave_value type(SWIG_ErrorType(code));
   std::string r = msg;
   r += " (" + type.string_value() + ")";
-  error(r.c_str());
+  error("%s",r.c_str());
   return octave_value(r);
 }

@@ -840,7 +840,7 @@
       const std::string opname = std::string("__") + octave_base_value::get_umap_name(umap) + std::string("__");
       octave_value ret;
       if (!dispatch_unary_op(opname, ret)) {
-        error((opname + std::string(" method not found")).c_str());
+        error("%s",(opname + std::string(" method not found")).c_str());
         return octave_value();
       }
       return ret;
wsfulton commented 5 years ago

We could do with fully testing Octave 5.1 on Travis, if someone can add a ppa like @kwwette used to, see: https://github.com/swig/swig/blob/b1f68b893b92cd34fb194f0458578826a7239a96/Tools/travis-linux-install.sh#L82-L97