summaryrefslogtreecommitdiff
path: root/gcc/intl
diff options
context:
space:
mode:
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2001-10-24 20:10:53 +0000
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2001-10-24 20:10:53 +0000
commit521369900202afd3918f5859d3da0e351b1e2a06 (patch)
treec0538b67d74f1cd1505eb648f2f17be9f0ccc09c /gcc/intl
parent10159af365137961781f9986bf6e66146277e5f7 (diff)
downloadgcc-521369900202afd3918f5859d3da0e351b1e2a06.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@46472 138bc75d-0d04-0410-961f-82ee72b054a4
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 f298b2e37ef..a677ba5e467 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 b6b13ff2cad..7055e52fadc 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