MDEV-39173 Replace sprintf with snprintf#4869
Conversation
…f with snprintf Remove the unscoped #pragma GCC diagnostic ignored "-Wdeprecated-declarations" from include/violite.h. The pragma was originally added to suppress OpenSSL deprecation warnings on macOS, but is no longer needed as modern macOS builds use bundled WolfSSL or external OpenSSL without deprecated declarations. The pragma also silently suppressed ~100 "sprintf is deprecated" warnings on macOS. Replace all sprintf/vsprintf calls with snprintf/vsnprintf across the codebase (118 files), excluding vendored third-party code (readline, wolfssl, wsrep-lib, libmariadb, groonga, zlib).
|
@gkodinov Could you please take a look as ticket reporter? |
There was a problem hiding this comment.
Thank you for attempting to fix this.
Unfortunately, it's not as simple as letting some AI do it.
You will need to find the actual size of the buffer and then set that as a limit.
In some cases the AI actually managed (mostly when the buffer is a local stack variable). But that's unfortunately not easy in cases where a bigger context is needed.
And it's especially impossible when certain assumptions are made couple of layers up.
Also, please resolve the merge conflicts. And any resulting buildbot failures.
One final thing: please rebase this to 10.11. This was the version decided as the best starting point after some deliberation.
| if (histfile) | ||
| { | ||
| sprintf(histfile,"%s/.mariadb_history", home); | ||
| snprintf(histfile, |
There was a problem hiding this comment.
That's not how you do this! It's about the size of the receiving buffer.
https://jira.mariadb.org/browse/MDEV-39173
Remove the unscoped #pragma GCC diagnostic ignored "-Wdeprecated-declarations" from include/violite.h. The pragma was originally added to suppress OpenSSL deprecation warnings on macOS, but is no longer needed as modern macOS builds use bundled WolfSSL or external OpenSSL without deprecated declarations.
The pragma also silently suppressed ~100 "sprintf is deprecated" warnings on macOS. Replace all sprintf/vsprintf calls with snprintf/vsnprintf across the codebase (118 files), excluding vendored third-party code (readline, wolfssl, wsrep-lib, libmariadb, groonga, zlib).