On 18.06.24 04:35, Andres Freund wrote:
On 2024-06-17 23:52:54 +0200, Daniel Gustafsson wrote:
Since sqlca is, according to our docs, present in other database systems we
should probably keep it a 5-char array for portability reasons. Adding a
padding character should be fine though.
How about, additionally, adding __attribute__((nonstring))? Wrapped in an
attribute, of course. That'll trigger warning for many unsafe uses, like
strlen().
It doesn't quite detect the problematic case in ecpg_log() though, seems it
doesn't understand fprintf() well enough (it does trigger in simple printf()
cases, because they get reduced to puts(), which it understands).
See also <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115513>.
Adding nonstring possibly allow us to re-enable -Wstringop-truncation,
Note that that would only work because we now always use our own
snprintf(), which is not covered by that option. I mean, we could still
do it, but it's not like the reasons we originally disabled that option
have actually gone away.