]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/elfxx-mips.c
Indent labels
[thirdparty/binutils-gdb.git] / bfd / elfxx-mips.c
index a05c67154cff3ac54df54127113ac8280b8a7aef..ae33acb8d5caa71ec560bf042810f3f45d4dc31c 100644 (file)
@@ -1413,18 +1413,23 @@ _bfd_mips_elf_read_ecoff_info (bfd *abfd, asection *section,
   /* The symbolic header contains absolute file offsets and sizes to
      read.  */
 #define READ(ptr, offset, count, size, type)                           \
-  if (symhdr->count == 0)                                              \
-    debug->ptr = NULL;                                                 \
-  else                                                                 \
+  do                                                                   \
     {                                                                  \
-      bfd_size_type amt = (bfd_size_type) size * symhdr->count;                \
-      debug->ptr = bfd_malloc (amt);                                   \
-      if (debug->ptr == NULL)                                          \
+      size_t amt;                                                      \
+      debug->ptr = NULL;                                               \
+      if (symhdr->count == 0)                                          \
+       break;                                                          \
+      if (_bfd_mul_overflow (size, symhdr->count, &amt))               \
+       {                                                               \
+         bfd_set_error (bfd_error_file_too_big);                       \
+         goto error_return;                                            \
+       }                                                               \
+      if (bfd_seek (abfd, symhdr->offset, SEEK_SET) != 0)              \
        goto error_return;                                              \
-      if (bfd_seek (abfd, symhdr->offset, SEEK_SET) != 0               \
-         || bfd_bread (debug->ptr, amt, abfd) != amt)                  \
+      debug->ptr = (type) _bfd_malloc_and_read (abfd, amt, amt);       \
+      if (debug->ptr == NULL)                                          \
        goto error_return;                                              \
-    }
+    } while (0)
 
   READ (line, cbLineOffset, cbLine, sizeof (unsigned char), unsigned char *);
   READ (external_dnr, cbDnOffset, idnMax, swap->external_dnr_size, void *);
@@ -13380,7 +13385,7 @@ _bfd_elf_mips_get_relocated_section_contents
     free (reloc_vector);
   return data;
 
-error_return:
+ error_return:
   if (reloc_vector != NULL)
     free (reloc_vector);
   return NULL;