[PATCH v2] gdb/nat/linux-osdata.c: fix build on gcc-12 (string overfow)
Simon Marchi
simon.marchi@polymtl.ca
Wed Nov 17 01:09:57 GMT 2021
On 2021-11-16 18:55, Sergei Trofimovich wrote:
> From: Sergei Trofimovich <siarheit@google.com>
>
> On gcc-12 build fails as:
>
> ../../gdbserver/../gdb/nat/linux-osdata.c: In function 'void linux_xfer_osdata_processes(buffer*)':
> ../../gdbserver/../gdb/nat/linux-osdata.c:330:39: error:
> '__builtin___sprintf_chk' may write a terminating nul past the end of the destination [-Werror=format-overflow=]
> 330 | sprintf (core_str, "%d", i);
> | ^
>
> It's an off-by-one case in an infeasible scenario for negative
> huge core count. The change switches to std::string for memory
> handling.
>
> Tested by running 'info os processes' and checking CPU cores column.
Thanks, this is ok. Do you have push access, or do you want me to push
it on your behalf?
Simon
More information about the Binutils
mailing list