clone45 / voxglitch

Modules for VCV Rack
GNU General Public License v3.0
101 stars 16 forks source link

Fails to build with -Werror=format-security #127

Closed dvzrv closed 2 years ago

dvzrv commented 2 years ago

Hi! When building voxglitch as part of cardinal, I have run into a build error due to unsafe use of format strings.

In file included from ../src/Rack/include/common.hpp:269,
                 from ../include/common.hpp:31,
                 from ../src/Rack/include/rack.hpp:22,
                 from ../include/rack.hpp:20,
                 from voxglitch/src/plugin.hpp:2,
                 from voxglitch/src/GrainFx.cpp:7:
voxglitch/src/Common/common.hpp: In member function ‘void Common::DEBUG_FLOAT(float)’:
../src/Rack/include/logger.hpp:13:45: error: format not a string literal and no format arguments [-Werror=format-security]
   13 | #define DEBUG(format, ...) rack::logger::log(rack::logger::DEBUG_LEVEL, __FILE__, __LINE__, __FUNCTION__, format, ##__VA_ARGS__)
      |                            ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
voxglitch/src/Common/common.hpp:25:7: note: in expansion of macro ‘DEBUG’
   25 |       DEBUG(std::to_string(value).c_str());
      |       ^~~~~
In file included from ../src/Rack/include/common.hpp:269,
                 from ../include/common.hpp:31,
                 from ../src/Rack/include/rack.hpp:22,
                 from ../include/rack.hpp:20,
                 from voxglitch/src/plugin.hpp:2,
                 from voxglitch/src/GrainEngineMK2.cpp:8:
voxglitch/src/Common/common.hpp: In member function ‘void Common::DEBUG_FLOAT(float)’:
../src/Rack/include/logger.hpp:13:45: error: format not a string literal and no format arguments [-Werror=format-security]
   13 | #define DEBUG(format, ...) rack::logger::log(rack::logger::DEBUG_LEVEL, __FILE__, __LINE__, __FUNCTION__, format, ##__VA_ARGS__)
      |                            ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
voxglitch/src/Common/common.hpp:25:7: note: in expansion of macro ‘DEBUG’
   25 |       DEBUG(std::to_string(value).c_str());
      |       ^~~~~
In file included from ../src/Rack/include/common.hpp:269,
                 from ../include/common.hpp:31,
                 from ../src/Rack/include/rack.hpp:22,
                 from ../include/rack.hpp:20,
                 from voxglitch/src/plugin.hpp:2,
                 from voxglitch/src/GrainEngineMK2Expander.cpp:6:
voxglitch/src/Common/common.hpp: In member function ‘void Common::DEBUG_FLOAT(float)’:
../src/Rack/include/logger.hpp:13:45: error: format not a string literal and no format arguments [-Werror=format-security]
   13 | #define DEBUG(format, ...) rack::logger::log(rack::logger::DEBUG_LEVEL, __FILE__, __LINE__, __FUNCTION__, format, ##__VA_ARGS__)
      |                            ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
voxglitch/src/Common/common.hpp:25:7: note: in expansion of macro ‘DEBUG’
   25 |       DEBUG(std::to_string(value).c_str());
      |       ^~~~~
clone45 commented 2 years ago

@dvzrv Hi David, I've updated the code to remove the DEBUG statement that was annoying the compiler. Would you be able to pull from the master branch and try again?

dvzrv commented 2 years ago

@clone45 thanks for the quick fix. There is another DEBUG() call in src/Ghosts/GhostsEx.hpp

clone45 commented 2 years ago

Hi @dvzrv , those debugs in GhostsEx.hpp are commented out. Let me know if they're causing problems.

dvzrv commented 2 years ago

Ah, I didn't spot the comments above/below when grepping for calls to DEBUG(). I guess that is all good then (I removed them via sed before build :) ).

clone45 commented 2 years ago

Awesome, keep me posted! Happy to help!