aboutsummaryrefslogtreecommitdiff
path: root/gcc/intl
diff options
context:
space:
mode:
authorZack Weinberg <zack@gcc.gnu.org>2001-10-24 20:10:53 +0000
committerZack Weinberg <zack@gcc.gnu.org>2001-10-24 20:10:53 +0000
commitb621a4ddc72206d4cef5f2957237d1f488e4660e (patch)
treec0538b67d74f1cd1505eb648f2f17be9f0ccc09c /gcc/intl
parent724035826b67d8c72b865893451555100f3d4af4 (diff)
downloadgcc-b621a4ddc72206d4cef5f2957237d1f488e4660e.zip
gcc-b621a4ddc72206d4cef5f2957237d1f488e4660e.tar.gz
gcc-b621a4ddc72206d4cef5f2957237d1f488e4660e.tar.bz2
c-common.h (struct c_common_identifier): Remove rid_code field.
* c-common.h (struct c_common_identifier): Remove rid_code field. (C_RID_CODE): Use ->node.rid_code instead of ->rid_code. * c-typeck.c (constructor_designated): New local flag. (struct constructor_stack): Add "designated" field to match. (start_init): Clear it. (really_start_incremental_init, push_init_level): Push and clear it. (pop_init_level): Pop it. (set_designator): Set it. (pop_init_level): Suppress "missing initializer" warnings if constructor_designated is true. (process_init_element): Suppress warning about union initialization under traditional C, if constructor_designated is true. * intl/loadmsgcat.c (INTTYPE_SIGNED, INTTYPE_MINIMUM, INTTYPE_MAXIMUM): Clone from system.h. (_nl_load_domain): Use them when testing for overflow of size_t. Cast result of sizeof to off_t to compare to st_size value. Move side effects out of conditional for comprehensibility. * testsuite/gcc.dg/20011021-1.c: New test. From-SVN: r46472
Diffstat (limited to 'gcc/intl')
-rw-r--r--gcc/intl/ChangeLog8
-rw-r--r--gcc/intl/loadmsgcat.c17
2 files changed, 23 insertions, 2 deletions
diff --git a/gcc/intl/ChangeLog b/gcc/intl/ChangeLog
index f298b2e..a677ba5 100644
--- a/gcc/intl/ChangeLog
+++ b/gcc/intl/ChangeLog
@@ -1,3 +1,11 @@
+2001-10-24 Zack Weinberg <zack@codesourcery.com>
+
+ * loadmsgcat.c (INTTYPE_SIGNED, INTTYPE_MINIMUM,
+ INTTYPE_MAXIMUM): Clone from system.h.
+ (_nl_load_domain): Use them when testing for overflow of size_t.
+ Cast result of sizeof to off_t to compare to st_size value.
+ Move side effects out of conditional for comprehensibility.
+
2001-10-21 Zack Weinberg <zack@codesourcery.com>
* dcigettext.c: Don't use #elif.
diff --git a/gcc/intl/loadmsgcat.c b/gcc/intl/loadmsgcat.c
index b6b13ff..7055e52 100644
--- a/gcc/intl/loadmsgcat.c
+++ b/gcc/intl/loadmsgcat.c
@@ -78,6 +78,15 @@ char *alloca ();
# include "../locale/localeinfo.h"
#endif
+/* GCC LOCAL: These macros are used below. */
+/* The extra casts work around common compiler bugs. */
+#define INTTYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
+ It is necessary at least when t == time_t. */
+#define INTTYPE_MINIMUM(t) ((t) (INTTYPE_SIGNED (t) \
+ ? ~ (t) 0 << (sizeof(t) * CHAR_BIT - 1) : (t) 0))
+#define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t)))
+
/* @@ end of prolog @@ */
#ifdef _LIBC
@@ -373,19 +382,23 @@ _nl_load_domain (domain_file, domainbinding)
return;
/* We must know about the size of the file. */
+ /* GCC_LOCAL: Use INTTYPE_MAXIMUM for overflow check, cast sizeof to
+ off_t, move set of size below if. */
if (
#ifdef _LIBC
__builtin_expect (fstat64 (fd, &st) != 0, 0)
#else
__builtin_expect (fstat (fd, &st) != 0, 0)
#endif
- || __builtin_expect ((size = (size_t) st.st_size) != st.st_size, 0)
- || __builtin_expect (size < sizeof (struct mo_file_header), 0))
+ || __builtin_expect (st.st_size > INTTYPE_MAXIMUM (ssize_t), 0)
+ || __builtin_expect (st.st_size < (off_t) sizeof (struct mo_file_header),
+ 0))
{
/* Something went wrong. */
close (fd);
return;
}
+ size = (size_t) st.st_size;
#ifdef HAVE_MMAP
/* Now we are ready to load the file. If mmap() is available we try