bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#32230: 27.0.50; GCC 7 warning due to -Wformat-overflow


From: Eli Zaretskii
Subject: bug#32230: 27.0.50; GCC 7 warning due to -Wformat-overflow
Date: Sat, 21 Jul 2018 09:53:04 +0300

> From: Ken Brown <kbrown@cornell.edu>
> Date: Fri, 20 Jul 2018 18:02:07 -0400
> Cc: Paul Eggert <eggert@cs.ucla.edu>
> 
> The Cygwin-w32 build has turned up another GCC 7 warning:
> 
> ../../master/src/w32term.c: In function ‘x_draw_glyph_string’:
> ../../master/src/w32term.c:1477:27: warning: ‘__builtin___sprintf_chk’ 
> may write a terminating nul past the end of the destination 
> [-Wformat-overflow=]
>      sprintf ((char *) buf, "%0*X",
>                             ^
> ../../master/src/w32term.c:1477:4: note: ‘__builtin___sprintf_chk’ 
> output between 5 and 8 bytes into a destination of size 7
>      sprintf ((char *) buf, "%0*X",
>      ^
> The method that Paul used in bug#32189 could be used here too, but I'm
> not sure it's worth the trouble.  My inclination is to just increase the
> buffer size from 7 to 8.

Yes, with a comment explaining why 8.

But do you understand why it says "between 5 and 8 bytes"?  The
corresponding argument to snprintf is either 4 or 6, so it should be
between 5 and 7.  Where could the extra byte come from?  Is that
because glyphless.ch is a 25-bit field?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]