about summary refs log tree commit diff
path: root/elf/dl-sysdep.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-07 17:37:06 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-07 17:37:06 +0000
commit4021079f5eb0ac9b1a0f3d791c628d7ce665ee57 (patch)
tree2ac4f7c92d8269bdac83d167a3fc82d9bfd81850 /elf/dl-sysdep.c
parent65302b6ec8c5aa89dbfcb8952ee0fb834a1b1d56 (diff)
downloadglibc-4021079f5eb0ac9b1a0f3d791c628d7ce665ee57.tar.gz
glibc-4021079f5eb0ac9b1a0f3d791c628d7ce665ee57.tar.xz
glibc-4021079f5eb0ac9b1a0f3d791c628d7ce665ee57.zip
* elf/dl-sysdep.c (_dl_important_hwcaps): Add integer overflow check.
	* elf/dl-minimal.c (__libc_memalign): Likewise.  Handle malloc (0).
	Return NULL if mmap failed instead of asserting it does not.
	(calloc): Check for integer overflow.

	* elf/dl-minimal.c (__strtoul_internal): Fix parsing of numbers bigger
	than LONG_MAX / 10.
Diffstat (limited to 'elf/dl-sysdep.c')
-rw-r--r--elf/dl-sysdep.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/elf/dl-sysdep.c b/elf/dl-sysdep.c
index d06ce1754e..4c6b3d1a64 100644
--- a/elf/dl-sysdep.c
+++ b/elf/dl-sysdep.c
@@ -460,9 +460,21 @@ _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
     total = temp[0].len + 1;
   else
     {
-      total = (1UL << (cnt - 2)) * (temp[0].len + temp[cnt - 1].len + 2);
-      for (n = 1; n + 1 < cnt; ++n)
-	total += (1UL << (cnt - 3)) * (temp[n].len + 1);
+      total = temp[0].len + temp[cnt - 1].len + 2;
+      if (cnt > 2)
+	{
+	  total <<= 1;
+	  for (n = 1; n + 1 < cnt; ++n)
+	    total += temp[n].len + 1;
+	  if (cnt > 3
+	      && (cnt >= sizeof (size_t) * 8
+		  || total + (sizeof (*result) << 3)
+		     >= (1UL << (sizeof (size_t) * 8 - cnt + 3))))
+	    _dl_signal_error (ENOMEM, NULL, NULL,
+			      N_("cannot create capability list"));
+
+	  total <<= cnt - 3;
+	}
     }
 
   /* The result structure: we use a very compressed way to store the