public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [Patch] Increase buffer size due to warning from ToT GCC
@ 2017-12-15 16:43 Steve Ellcey
  2017-12-15 16:59 ` Joseph Myers
  0 siblings, 1 reply; 2+ messages in thread
From: Steve Ellcey @ 2017-12-15 16:43 UTC (permalink / raw)
  To: libc-alpha

I ran into another error while building ToT glibc with ToT GCC.

dbg_log.c: In function ‘dbg_log’:
dbg_log.c:71:46: error: ‘%s’ directive output may be truncated writing up to 511 bytes into a region of size between 241 and 506 [-Werror=format-truncation=]
       snprintf (msg, sizeof (msg), "%s - %d: %s%s", buf, getpid (), msg2,
                                              ^~                     ~~~~
In file included from ../libio/stdio.h:862,
                 from ../include/stdio.h:2,
                 from dbg_log.c:19:
../libio/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output between 7 and 784 bytes into a destination of size 512
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        __bos (__s), __fmt, __va_arg_pack ());
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
../o-iterator.mk:9: recipe for target '/home/sellcey/tot/obj/glibc64/nscd/dbg_log.o' failed
make[2]: *** [/home/sellcey/tot/obj/glibc64/nscd/dbg_log.o] Error 1


Here is a patch to fix it, OK to checkin?


2017-12-15  Steve Ellcey  <sellcey@cavium.com>

	* nscd/dbg_log.c (dbg_log): Increase msg buffer size.


diff --git a/nscd/dbg_log.c b/nscd/dbg_log.c
index d4b19ac..2190c16 100644
--- a/nscd/dbg_log.c
+++ b/nscd/dbg_log.c
@@ -67,7 +67,7 @@ dbg_log (const char *fmt,...)
       char buf[256];
       strftime (buf, sizeof (buf), "%c", &now);
 
-      char msg[512];
+      char msg[1024];
       snprintf (msg, sizeof (msg), "%s - %d: %s%s", buf, getpid (), msg2,
 		msg2[strlen (msg2) - 1] == '\n' ? "" : "\n");
       if (dbgout)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Patch] Increase buffer size due to warning from ToT GCC
  2017-12-15 16:43 [Patch] Increase buffer size due to warning from ToT GCC Steve Ellcey
@ 2017-12-15 16:59 ` Joseph Myers
  0 siblings, 0 replies; 2+ messages in thread
From: Joseph Myers @ 2017-12-15 16:59 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: libc-alpha

On Fri, 15 Dec 2017, Steve Ellcey wrote:

> Here is a patch to fix it, OK to checkin?

OK.  (I doubt there would actually be truncation here, but it's 
locale-dependent, so making this buffer large enough to ensure that only 
the previous format operations can result in truncation, and this one 
can't, seems reasonable.)

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-15 16:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-15 16:43 [Patch] Increase buffer size due to warning from ToT GCC Steve Ellcey
2017-12-15 16:59 ` Joseph Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).