mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
* 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.
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/* Operating system support for run-time dynamic linker. Generic Unix version.
|
||||
Copyright (C) 1995-1998, 2000-2005, 2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995-1998, 2000-2006, 2007 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
|
||||
@ -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_("Xcannot create capability list"));
|
||||
|
||||
total <<= cnt - 3;
|
||||
}
|
||||
}
|
||||
|
||||
/* The result structure: we use a very compressed way to store the
|
||||
|
Reference in New Issue
Block a user