[PATCH v2] gdb/nat/linux-osdata.c: fix build on gcc-12 (string overfow)

Sergei Trofimovich slyich@gmail.com
Wed Nov 17 08:29:02 GMT 2021


On Tue, 16 Nov 2021 20:09:57 -0500
Simon Marchi <simon.marchi@polymtl.ca> wrote:

> 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?

Pushed as:
    https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=486f9e20e037f1eea2dce98dc393db60df5feef3

Thank you!

-- 

  Sergei


More information about the Binutils mailing list