Menu

Commit [r13005]  Maximize  Restore  History

Finish the sprintf conversion in the grammar fragments and lint.c

Follow-on to r13004. -Wformat-overflow goes from 14 to 7, and a full build from
737 to 730 warnings.

GCC only flags the calls whose overflow it can demonstrate; the rest of the raw
sprintf() calls in the same files are exactly as unchecked, they just have
arguments it cannot bound. So rather than convert the seven it named, this
converts every remaining sprintf() in the files that owned them - 44 calls in
compilers/sql/80.reqd, compilers/sqlcmd/80.reqd,
compilers/4glc/rules/sqlpack/infx/sql1.rule and compilers/4glc/lint.c.

Every destination in those files is either a local char buff[N] or the parser's
$<str>$, which is the char str[1024] member of the %union - both arrays, so
sizeof() in the SPRINTFn macro measures the real space and A4GL_sprintf raises
its assertion, naming file and line, when the result will not fit. Which is the
point: we do not need to know in advance whether a 2k buffer can overflow, we
need it to stop loudly on the day it does.

(lint.c has one static char *buff, in local_xml_escape(), which builds its
string by hand and is not a sprintf destination - so no call was converted to a
macro that would silently take the unchecked pointer path.)

The remaining 7 are the two files that cannot use the macro at all, as noted in
r13004: compilers/xgen/x.yacc (5), where bin/xgen is a bootstrap tool linking no
library, and lib/libui/ui_xml/proxy.c (2), which includes only system headers.

mikeaubury 1 day ago

changed /aubit4glsrc/trunk/compilers/4glc/lint.c
changed /aubit4glsrc/trunk/compilers/4glc/rules/sqlpack/infx/sql1.rule
changed /aubit4glsrc/trunk/compilers/sql/80.reqd
changed /aubit4glsrc/trunk/compilers/sqlcmd/80.reqd
/aubit4glsrc/trunk/compilers/4glc/lint.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/4glc/rules/sqlpack/infx/sql1.rule Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/sql/80.reqd Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/sqlcmd/80.reqd Diff Switch to side-by-side view
Loading...