This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] Increase buffer size due to warning from ToT GCC


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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]