This is the mail archive of the glibc-cvs@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]

GNU C Library master sources branch master updated. glibc-2.24-628-g38d01bd


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  38d01bd6df937f69c881df61b111492e941f2b74 (commit)
      from  64235ccc11175e6d4186a8fa911816cd7674d453 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=38d01bd6df937f69c881df61b111492e941f2b74

commit 38d01bd6df937f69c881df61b111492e941f2b74
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Wed Jan 11 13:57:59 2017 +0000

    Fix elf/sotruss-lib format-truncation error.
    
    Building 64-bit glibc with GCC mainline fails with:
    
    ../elf/sotruss-lib.c: In function 'la_version':
    ../elf/sotruss-lib.c:91:28: error: '%lu' directive output may be truncated writing between 1 and 20 bytes into a region of size 11 [-Werror=format-truncation=]
          snprintf (endp, 12, ".%lu", (unsigned long int) pid);
                                ^~~
    ../elf/sotruss-lib.c:91:26: note: using the range [1, 18446744073709551615] for directive argument
          snprintf (endp, 12, ".%lu", (unsigned long int) pid);
                              ^~~~~~
    ../elf/sotruss-lib.c:91:6: note: format output between 3 and 22 bytes into a destination of size 12
          snprintf (endp, 12, ".%lu", (unsigned long int) pid);
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    Pids from getpid cannot actually be negative, but the compiler doesn't
    know this.  Other places in this file use (signed) long int for
    printing, so this patch makes this place do so as well.  Then it
    increases the buffer size by one byte to allow for the minus sign that
    can't actually occur.  It doesn't seem worth using diagnostic pragmas
    to save one byte; other place in this file just use a cruder 3 *
    sizeof (pid_t) calculation for number of digits.
    
    Tested with GCC mainline with compilation for aarch64 with
    build-many-glibcs.py, and with glibc testsuite for x86_64 (built with
    GCC 6).
    
    	* elf/sotruss-lib.c (init): Increase space allocated for pid by
    	one byte.  Print it with %ld, cast to long int.

diff --git a/ChangeLog b/ChangeLog
index 4f87985..fe612a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-01-11  Joseph Myers  <joseph@codesourcery.com>
+
+	* elf/sotruss-lib.c (init): Increase space allocated for pid by
+	one byte.  Print it with %ld, cast to long int.
+
 2017-01-11  Szabolcs Nagy  <szabolcs.nagy@arm.com>
 
 	* scripts/build-many-glibcs.py (os.cpu_count): Add compatibility definition.
diff --git a/elf/sotruss-lib.c b/elf/sotruss-lib.c
index a27ab9f..da2fedd 100644
--- a/elf/sotruss-lib.c
+++ b/elf/sotruss-lib.c
@@ -84,11 +84,11 @@ init (void)
 
       if (out_filename != NULL && out_filename[0] != 0)
 	{
-	  size_t out_filename_len = strlen (out_filename) + 12;
+	  size_t out_filename_len = strlen (out_filename) + 13;
 	  char fullname[out_filename_len];
 	  char *endp = stpcpy (fullname, out_filename);
 	  if (which_process == NULL || which_process[0] == '\0')
-	    snprintf (endp, 12, ".%lu", (unsigned long int) pid);
+	    snprintf (endp, 13, ".%ld", (long int) pid);
 
 	  out_fd = open (fullname, O_RDWR | O_CREAT | O_TRUNC, 0666);
 	  if (out_fd != -1)

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog         |    5 +++++
 elf/sotruss-lib.c |    4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


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