changeset 37398:4f68c2c2f9b9

Sync up error.c with glibc This is a partial sync-up of error.c with glibc. The following changes went in: - Get rid of the INTUSE macro - Remove unused macro ALLOCA_LIMIT - Fix a potential buffer overflow in error_tail (sourceware bz #15672) - Fix a potential NULL dereference in strcmp error: Sync from glibc master * lib/error.c [_LIBC]: Remove INTUSE usage. (error_tail): Remove unused macro ALLOCA_LIMIT. Fix potential buffer overflow. Fix potential NULL dereference in strcmp.
author Siddhesh Poyarekar <siddhesh@redhat.com>
date Wed, 09 Jul 2014 15:26:17 +0530
parents c5ffd2dab9b0
children 079544b0c4fe
files ChangeLog lib/error.c
diffstat 2 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jul 09 13:13:07 2014 +0200
+++ b/ChangeLog	Wed Jul 09 15:26:17 2014 +0530
@@ -1,3 +1,11 @@
+2014-07-10  Siddhesh Poyarekar  <siddhesh@redhat.com>
+
+	error: Sync from glibc master
+	* lib/error.c [_LIBC]: Remove INTUSE usage.
+	(error_tail): Remove unused macro ALLOCA_LIMIT.
+	Fix potential buffer overflow.  Fix potential NULL dereference
+	in strcmp.
+
 2014-07-09  Pavel Hrdina  <phrdina@redhat.com> (tiny change)
 
 	nl_langinfo: fix build under mingw
--- a/lib/error.c	Wed Jul 09 13:13:07 2014 +0200
+++ b/lib/error.c	Wed Jul 09 15:26:17 2014 +0530
@@ -77,9 +77,9 @@
 # define error_at_line __error_at_line
 
 # include <libio/iolibio.h>
-# define fflush(s) INTUSE(_IO_fflush) (s)
+# define fflush(s) _IO_fflush (s)
 # undef putc
-# define putc(c, fp) INTUSE(_IO_putc) (c, fp)
+# define putc(c, fp) _IO_putc (c, fp)
 
 # include <bits/libc-lock.h>
 
@@ -201,7 +201,6 @@
 #if _LIBC
   if (_IO_fwide (stderr, 0) > 0)
     {
-# define ALLOCA_LIMIT 2000
       size_t len = strlen (message) + 1;
       wchar_t *wmessage = NULL;
       mbstate_t st;
@@ -237,7 +236,7 @@
           if (res != len)
             break;
 
-          if (__builtin_expect (len >= SIZE_MAX / 2, 0))
+          if (__builtin_expect (len >= SIZE_MAX / sizeof (wchar_t) / 2, 0))
             {
               /* This really should not happen if everything is fine.  */
               res = (size_t) -1;
@@ -342,7 +341,10 @@
 
       if (old_line_number == line_number
           && (file_name == old_file_name
-              || strcmp (old_file_name, file_name) == 0))
+              || (old_file_name != NULL
+                  && file_name != NULL
+                  && strcmp (old_file_name, file_name) == 0)))
+
         /* Simply return and print nothing.  */
         return;