[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commits] r17886 - in /fsf/trunk/libc: ./ csu/ stdio-common/ string/ sysdeps/i386/ sysdeps/mach/hurd/i386/ sysdeps/mach/hurd/powerpc/ ...
- To: commits@xxxxxxxxxx
- Subject: [Commits] r17886 - in /fsf/trunk/libc: ./ csu/ stdio-common/ string/ sysdeps/i386/ sysdeps/mach/hurd/i386/ sysdeps/mach/hurd/powerpc/ ...
- From: eglibc@xxxxxxxxxx
- Date: Tue, 03 Apr 2012 00:01:58 -0000
Author: eglibc
Date: Tue Apr 3 00:01:57 2012
New Revision: 17886
Log:
Import glibc-mainline for 2012-04-03
Modified:
fsf/trunk/libc/ChangeLog
fsf/trunk/libc/csu/init-first.c
fsf/trunk/libc/stdio-common/bug22.c
fsf/trunk/libc/stdio-common/printf-parse.h
fsf/trunk/libc/stdio-common/printf-parsemb.c
fsf/trunk/libc/stdio-common/vfprintf.c
fsf/trunk/libc/string/test-memcmp.c
fsf/trunk/libc/string/test-strcmp.c
fsf/trunk/libc/string/test-string.h
fsf/trunk/libc/sysdeps/i386/init-first.c
fsf/trunk/libc/sysdeps/mach/hurd/i386/init-first.c
fsf/trunk/libc/sysdeps/mach/hurd/powerpc/init-first.c
fsf/trunk/libc/sysdeps/sh/init-first.c
fsf/trunk/libc/time/tst-mktime2.c
Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Tue Apr 3 00:01:57 2012
@@ -1,3 +1,33 @@
+2012-04-02 David S. Miller <davem@xxxxxxxxxxxxx>
+
+ With help from Paul Eggert, Carlos O'Donell, and Roland McGrath.
+ * stdio-common/printf-parse.h (read_int): Change return type to
+ 'int', return -1 on INT_MAX overflow.
+ * stdio-common/vfprintf.c (vfprintf): Validate width and precision
+ against overflow of INT_MAX. Set errno to EOVERFLOW when 'done'
+ overflows INT_MAX. Check for overflow of in-format-string precision
+ values properly. Use EOVERFLOW rather than ERANGE throughout. Use
+ SIZE_MAX not INT_MAX for integer overflow test.
+ * stdio-common/printf-parsemb.c: If read_int signals an overflow,
+ skip the construct in the format string but do not record anything.
+ * stdio-common/bug22.c: Adjust to test both width/prevision
+ INT_MAX overflow as well as total length INT_MAX overflow. Check
+ explicitly for proper errno values.
+
+2012-04-02 Thomas Schwinge <thomas@xxxxxxxxxxxxxxxx>
+
+ * string/test-memcmp.c [! WIDE]: #include <limits.h> for CHAR_MIN,
+ CHAR_MAX.
+ * string/test-strcmp.c [! WIDE]: Likewise.
+ * time/tst-mktime2.c: Likewise for INT_MAX.
+ * string/test-string.h: #include <sys/param.h> for MIN.
+
+ * csu/init-first.c (__libc_init_first): Call __ctype_init.
+ * sysdeps/i386/init-first.c (init): Likewise.
+ * sysdeps/mach/hurd/i386/init-first.c (posixland_init): Likewise.
+ * sysdeps/mach/hurd/powerpc/init-first.c (posixland_init): Likewise.
+ * sysdeps/sh/init-first.c (init): Likewise.
+
2012-04-01 Ulrich Drepper <drepper@xxxxxxxxx>
* po/ru.po: Update from translation team.
Modified: fsf/trunk/libc/csu/init-first.c
==============================================================================
--- fsf/trunk/libc/csu/init-first.c (original)
+++ fsf/trunk/libc/csu/init-first.c Tue Apr 3 00:01:57 2012
@@ -1,5 +1,5 @@
/* Initialization code run first thing by the ELF startup code. Stub version.
- Copyright (C) 1995, 1997, 1998, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1995-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,6 +16,7 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <ctype.h>
#include <unistd.h>
#include <sys/types.h>
@@ -55,4 +56,7 @@
/* This is a hack to make the special getopt in GNU libc working. */
__getopt_clean_environment (envp);
#endif
+
+ /* Initialize ctype data. */
+ __ctype_init ();
}
Modified: fsf/trunk/libc/stdio-common/bug22.c
==============================================================================
--- fsf/trunk/libc/stdio-common/bug22.c (original)
+++ fsf/trunk/libc/stdio-common/bug22.c Tue Apr 3 00:01:57 2012
@@ -1,12 +1,22 @@
/* BZ #5424 */
#include <stdio.h>
+#include <errno.h>
+/* INT_MAX + 1 */
#define N 2147483648
+
+/* (INT_MAX / 2) + 2 */
+#define N2 1073741825
+
+/* INT_MAX - 3 */
+#define N3 2147483644
#define STRINGIFY(S) #S
#define MAKE_STR(S) STRINGIFY(S)
#define SN MAKE_STR(N)
+#define SN2 MAKE_STR(N2)
+#define SN3 MAKE_STR(N3)
static int
do_test (void)
@@ -20,11 +30,25 @@
return 1;
}
- ret = fprintf (fp, "%" SN "d%" SN "d", 1, 1);
+ ret = fprintf (fp, "%" SN "d", 1);
+ printf ("ret = %d\n", ret);
+ if (ret != -1 || errno != EOVERFLOW)
+ return 1;
+ ret = fprintf (fp, "%." SN "d", 1);
+ printf ("ret = %d\n", ret);
+ if (ret != -1 || errno != EOVERFLOW)
+ return 1;
+
+ ret = fprintf (fp, "%." SN3 "d", 1);
+ printf ("ret = %d\n", ret);
+ if (ret != -1 || errno != EOVERFLOW)
+ return 1;
+
+ ret = fprintf (fp, "%" SN2 "d%" SN2 "d", 1, 1);
printf ("ret = %d\n", ret);
- return ret != -1;
+ return ret != -1 || errno != EOVERFLOW;
}
#define TIMEOUT 30
Modified: fsf/trunk/libc/stdio-common/printf-parse.h
==============================================================================
--- fsf/trunk/libc/stdio-common/printf-parse.h (original)
+++ fsf/trunk/libc/stdio-common/printf-parse.h Tue Apr 3 00:01:57 2012
@@ -68,16 +68,27 @@
#ifndef DONT_NEED_READ_INT
/* Read a simple integer from a string and update the string pointer.
It is assumed that the first character is a digit. */
-static unsigned int
+static int
read_int (const UCHAR_T * *pstr)
{
- unsigned int retval = **pstr - L_('0');
+ int retval = **pstr - L_('0');
while (ISDIGIT (*++(*pstr)))
- {
- retval *= 10;
- retval += **pstr - L_('0');
- }
+ if (retval >= 0)
+ {
+ if (INT_MAX / 10 < retval)
+ retval = -1;
+ else
+ {
+ int digit = **pstr - L_('0');
+
+ retval *= 10;
+ if (INT_MAX - digit < retval)
+ retval = -1;
+ else
+ retval += digit;
+ }
+ }
return retval;
}
Modified: fsf/trunk/libc/stdio-common/printf-parsemb.c
==============================================================================
--- fsf/trunk/libc/stdio-common/printf-parsemb.c (original)
+++ fsf/trunk/libc/stdio-common/printf-parsemb.c Tue Apr 3 00:01:57 2012
@@ -87,12 +87,15 @@
n = read_int (&format);
- if (n > 0 && *format == L_('$'))
+ if (n != 0 && *format == L_('$'))
/* Is positional parameter. */
{
++format; /* Skip the '$'. */
- spec->data_arg = n - 1;
- *max_ref_arg = MAX (*max_ref_arg, n);
+ if (n != -1)
+ {
+ spec->data_arg = n - 1;
+ *max_ref_arg = MAX (*max_ref_arg, n);
+ }
}
else
/* Oops; that was actually the width and/or 0 padding flag.
@@ -160,10 +163,13 @@
/* The width argument might be found in a positional parameter. */
n = read_int (&format);
- if (n > 0 && *format == L_('$'))
+ if (n != 0 && *format == L_('$'))
{
- spec->width_arg = n - 1;
- *max_ref_arg = MAX (*max_ref_arg, n);
+ if (n != -1)
+ {
+ spec->width_arg = n - 1;
+ *max_ref_arg = MAX (*max_ref_arg, n);
+ }
++format; /* Skip '$'. */
}
}
@@ -177,9 +183,13 @@
}
}
else if (ISDIGIT (*format))
- /* Constant width specification. */
- spec->info.width = read_int (&format);
-
+ {
+ int n = read_int (&format);
+
+ /* Constant width specification. */
+ if (n != -1)
+ spec->info.width = n;
+ }
/* Get the precision. */
spec->prec_arg = -1;
/* -1 means none given; 0 means explicit 0. */
@@ -196,10 +206,13 @@
{
n = read_int (&format);
- if (n > 0 && *format == L_('$'))
+ if (n != 0 && *format == L_('$'))
{
- spec->prec_arg = n - 1;
- *max_ref_arg = MAX (*max_ref_arg, n);
+ if (n != -1)
+ {
+ spec->prec_arg = n - 1;
+ *max_ref_arg = MAX (*max_ref_arg, n);
+ }
++format;
}
}
@@ -213,7 +226,12 @@
}
}
else if (ISDIGIT (*format))
- spec->info.prec = read_int (&format);
+ {
+ int n = read_int (&format);
+
+ if (n != -1)
+ spec->info.prec = n;
+ }
else
/* "%.?" is treated like "%.0?". */
spec->info.prec = 0;
Modified: fsf/trunk/libc/stdio-common/vfprintf.c
==============================================================================
--- fsf/trunk/libc/stdio-common/vfprintf.c (original)
+++ fsf/trunk/libc/stdio-common/vfprintf.c Tue Apr 3 00:01:57 2012
@@ -67,10 +67,10 @@
do { \
unsigned int _val = val; \
assert ((unsigned int) done < (unsigned int) INT_MAX); \
- if (__builtin_expect ((unsigned int) INT_MAX - (unsigned int) done \
- < _val, 0)) \
+ if (__builtin_expect (INT_MAX - done < _val, 0)) \
{ \
done = -1; \
+ __set_errno (EOVERFLOW); \
goto all_done; \
} \
done += _val; \
@@ -141,12 +141,17 @@
do \
{ \
assert ((size_t) done <= (size_t) INT_MAX); \
- if ((size_t) PUT (s, (String), (Len)) != (size_t) (Len) \
- || (size_t) INT_MAX - (size_t) done < (size_t) (Len)) \
+ if ((size_t) PUT (s, (String), (Len)) != (size_t) (Len)) \
{ \
done = -1; \
goto all_done; \
} \
+ if (__builtin_expect (INT_MAX - done < (Len), 0)) \
+ { \
+ done = -1; \
+ __set_errno (EOVERFLOW); \
+ goto all_done; \
+ } \
done += (Len); \
} \
while (0)
@@ -1435,10 +1440,21 @@
const UCHAR_T *tmp; /* Temporary value. */
tmp = ++f;
- if (ISDIGIT (*tmp) && read_int (&tmp) && *tmp == L_('$'))
- /* The width comes from a positional parameter. */
- goto do_positional;
-
+ if (ISDIGIT (*tmp))
+ {
+ int pos = read_int (&tmp);
+
+ if (pos == -1)
+ {
+ __set_errno (EOVERFLOW);
+ done = -1;
+ goto all_done;
+ }
+
+ if (pos && *tmp == L_('$'))
+ /* The width comes from a positional parameter. */
+ goto do_positional;
+ }
width = va_arg (ap, int);
/* Negative width means left justified. */
@@ -1449,9 +1465,9 @@
left = 1;
}
- if (__builtin_expect (width >= (size_t) -1 / sizeof (CHAR_T) - 32, 0))
+ if (__builtin_expect (width >= INT_MAX / sizeof (CHAR_T) - 32, 0))
{
- __set_errno (ERANGE);
+ __set_errno (EOVERFLOW);
done = -1;
goto all_done;
}
@@ -1481,9 +1497,10 @@
LABEL (width):
width = read_int (&f);
- if (__builtin_expect (width >= (size_t) -1 / sizeof (CHAR_T) - 32, 0))
+ if (__builtin_expect (width == -1
+ || width >= INT_MAX / sizeof (CHAR_T) - 32, 0))
{
- __set_errno (ERANGE);
+ __set_errno (EOVERFLOW);
done = -1;
goto all_done;
}
@@ -1518,10 +1535,21 @@
const UCHAR_T *tmp; /* Temporary value. */
tmp = ++f;
- if (ISDIGIT (*tmp) && read_int (&tmp) > 0 && *tmp == L_('$'))
- /* The precision comes from a positional parameter. */
- goto do_positional;
-
+ if (ISDIGIT (*tmp))
+ {
+ int pos = read_int (&tmp);
+
+ if (pos == -1)
+ {
+ __set_errno (EOVERFLOW);
+ done = -1;
+ goto all_done;
+ }
+
+ if (pos && *tmp == L_('$'))
+ /* The precision comes from a positional parameter. */
+ goto do_positional;
+ }
prec = va_arg (ap, int);
/* If the precision is negative the precision is omitted. */
@@ -1529,15 +1557,26 @@
prec = -1;
}
else if (ISDIGIT (*f))
- prec = read_int (&f);
+ {
+ prec = read_int (&f);
+
+ /* The precision was specified in this case as an extremely
+ large positive value. */
+ if (prec == -1)
+ {
+ __set_errno (EOVERFLOW);
+ done = -1;
+ goto all_done;
+ }
+ }
else
prec = 0;
if (prec > width
&& prec > sizeof (work_buffer) / sizeof (work_buffer[0]) - 32)
{
- if (__builtin_expect (prec >= (size_t) -1 / sizeof (CHAR_T) - 32, 0))
+ if (__builtin_expect (prec >= INT_MAX / sizeof (CHAR_T) - 32, 0))
{
- __set_errno (ERANGE);
+ __set_errno (EOVERFLOW);
done = -1;
goto all_done;
}
@@ -1710,9 +1749,9 @@
+ sizeof (*args_type));
/* Check for potential integer overflow. */
- if (__builtin_expect (nargs > SIZE_MAX / bytes_per_arg, 0))
+ if (__builtin_expect (nargs > INT_MAX / bytes_per_arg, 0))
{
- __set_errno (ERANGE);
+ __set_errno (EOVERFLOW);
done = -1;
goto all_done;
}
Modified: fsf/trunk/libc/string/test-memcmp.c
==============================================================================
--- fsf/trunk/libc/string/test-memcmp.c (original)
+++ fsf/trunk/libc/string/test-memcmp.c Tue Apr 3 00:01:57 2012
@@ -1,5 +1,5 @@
/* Test and measure memcmp functions.
- Copyright (C) 1999, 2002, 2003, 2005, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1999-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Jakub Jelinek <jakub@xxxxxxxxxx>, 1999.
Added wmemcmp support by Liubov Dmitrieva <liubov.dmitrieva@xxxxxxxxx>, 2011.
@@ -44,6 +44,8 @@
return ret;
}
#else
+# include <limits.h>
+
# define MEMCMP memcmp
# define MEMCPY memcpy
# define SIMPLE_MEMCMP simple_memcmp
Modified: fsf/trunk/libc/string/test-strcmp.c
==============================================================================
--- fsf/trunk/libc/string/test-strcmp.c (original)
+++ fsf/trunk/libc/string/test-strcmp.c Tue Apr 3 00:01:57 2012
@@ -1,5 +1,5 @@
/* Test and measure strcmp and wcscmp functions.
- Copyright (C) 1999, 2002, 2003, 2005, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1999-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Jakub Jelinek <jakub@xxxxxxxxxx>, 1999.
Added wcscmp support by Liubov Dmitrieva <liubov.dmitrieva@xxxxxxxxx>, 2011.
@@ -80,6 +80,8 @@
}
#else
+# include <limits.h>
+
# define L(str) str
# define STRCMP strcmp
# define STRCPY strcpy
Modified: fsf/trunk/libc/string/test-string.h
==============================================================================
--- fsf/trunk/libc/string/test-string.h (original)
+++ fsf/trunk/libc/string/test-string.h Tue Apr 3 00:01:57 2012
@@ -1,5 +1,5 @@
/* Test and measure string and memory functions.
- Copyright (C) 1999, 2002, 2004, 2008, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1999-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Jakub Jelinek <jakub@xxxxxxxxxx>, 1999.
@@ -44,6 +44,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
+#include <sys/param.h>
#include <unistd.h>
#include <fcntl.h>
#include <error.h>
Modified: fsf/trunk/libc/sysdeps/i386/init-first.c
==============================================================================
--- fsf/trunk/libc/sysdeps/i386/init-first.c (original)
+++ fsf/trunk/libc/sysdeps/i386/init-first.c Tue Apr 3 00:01:57 2012
@@ -1,5 +1,5 @@
/* Initialization code run first thing by the ELF startup code. For i386/Unix.
- Copyright (C) 1995,1996,1997,2000,2001,2002 Free Software Foundation, Inc.
+ Copyright (C) 1995-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,6 +16,7 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <ctype.h>
#include <unistd.h>
extern void __libc_init (int, char **, char **);
@@ -40,6 +41,9 @@
/* This is a hack to make the special getopt in GNU libc working. */
__getopt_clean_environment (envp);
#endif
+
+ /* Initialize ctype data. */
+ __ctype_init ();
}
#ifdef SHARED
Modified: fsf/trunk/libc/sysdeps/mach/hurd/i386/init-first.c
==============================================================================
--- fsf/trunk/libc/sysdeps/mach/hurd/i386/init-first.c (original)
+++ fsf/trunk/libc/sysdeps/mach/hurd/i386/init-first.c Tue Apr 3 00:01:57 2012
@@ -1,6 +1,5 @@
/* Initialization code run first thing by the ELF startup code. For i386/Hurd.
- Copyright (C) 1995,96,97,98,99,2000,01,02,03,04,05
- Free Software Foundation, Inc.
+ Copyright (C) 1995-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -18,6 +17,7 @@
<http://www.gnu.org/licenses/>. */
#include <assert.h>
+#include <ctype.h>
#include <hurd.h>
#include <stdio.h>
#include <unistd.h>
@@ -90,6 +90,9 @@
/* This is a hack to make the special getopt in GNU libc working. */
__getopt_clean_environment (envp);
#endif
+
+ /* Initialize ctype data. */
+ __ctype_init ();
#if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS
__libc_global_ctors ();
Modified: fsf/trunk/libc/sysdeps/mach/hurd/powerpc/init-first.c
==============================================================================
--- fsf/trunk/libc/sysdeps/mach/hurd/powerpc/init-first.c (original)
+++ fsf/trunk/libc/sysdeps/mach/hurd/powerpc/init-first.c Tue Apr 3 00:01:57 2012
@@ -1,5 +1,5 @@
/* Initialization code run first thing by the ELF startup code. PowerPC/Hurd.
- Copyright (C) 1995-2001, 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1995-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -17,6 +17,7 @@
<http://www.gnu.org/licenses/>. */
#include <assert.h>
+#include <ctype.h>
#include <hurd.h>
#include <stdio.h>
#include <unistd.h>
@@ -80,6 +81,9 @@
/* This is a hack to make the special getopt in GNU libc working. */
__getopt_clean_environment (__environ);
#endif
+
+ /* Initialize ctype data. */
+ __ctype_init ();
#if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS
__libc_global_ctors ();
Modified: fsf/trunk/libc/sysdeps/sh/init-first.c
==============================================================================
--- fsf/trunk/libc/sysdeps/sh/init-first.c (original)
+++ fsf/trunk/libc/sysdeps/sh/init-first.c Tue Apr 3 00:01:57 2012
@@ -1,5 +1,5 @@
/* Initialization code run first thing by the ELF startup code. For SH.
- Copyright (C) 1995-1998, 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1995-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,6 +16,7 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <ctype.h>
#include <unistd.h>
extern void __libc_init (int, char **, char **);
@@ -40,6 +41,9 @@
/* This is a hack to make the special getopt in GNU libc working. */
__getopt_clean_environment (envp);
#endif
+
+ /* Initialize ctype data. */
+ __ctype_init ();
}
#ifdef SHARED
Modified: fsf/trunk/libc/time/tst-mktime2.c
==============================================================================
--- fsf/trunk/libc/time/tst-mktime2.c (original)
+++ fsf/trunk/libc/time/tst-mktime2.c Tue Apr 3 00:01:57 2012
@@ -1,4 +1,6 @@
/* Test program from Paul Eggert and Tony Leneis. */
+
+#include <limits.h>
#include <time.h>
#include <stdlib.h>
#include <unistd.h>
_______________________________________________
Commits mailing list
Commits@xxxxxxxxxx
http://eglibc.org/cgi-bin/mailman/listinfo/commits