Blame mono-debugger-2.10-libiberty.patch
|
Timotheus Pokorra |
70ff62b |
--- a/sysdeps/bfd/libiberty/objalloc.c 2012/03/06 15:51:48 184997
|
|
Timotheus Pokorra |
70ff62b |
+++ b/sysdeps/bfd/libiberty/objalloc.c 2012/09/18 08:34:05 191413
|
|
Timotheus Pokorra |
70ff62b |
@@ -1,5 +1,5 @@
|
|
Timotheus Pokorra |
70ff62b |
/* objalloc.c -- routines to allocate memory for objects
|
|
Timotheus Pokorra |
70ff62b |
- Copyright 1997 Free Software Foundation, Inc.
|
|
Timotheus Pokorra |
70ff62b |
+ Copyright 1997-2012 Free Software Foundation, Inc.
|
|
Timotheus Pokorra |
70ff62b |
Written by Ian Lance Taylor, Cygnus Solutions.
|
|
Timotheus Pokorra |
70ff62b |
|
|
Timotheus Pokorra |
70ff62b |
This program is free software; you can redistribute it and/or modify it
|
|
Timotheus Pokorra |
70ff62b |
@@ -114,10 +114,9 @@
|
|
Timotheus Pokorra |
70ff62b |
/* Allocate space from an objalloc structure. */
|
|
Timotheus Pokorra |
70ff62b |
|
|
Timotheus Pokorra |
70ff62b |
PTR
|
|
Timotheus Pokorra |
70ff62b |
-_objalloc_alloc (o, len)
|
|
Timotheus Pokorra |
70ff62b |
- struct objalloc *o;
|
|
Timotheus Pokorra |
70ff62b |
- unsigned long len;
|
|
Timotheus Pokorra |
70ff62b |
+_objalloc_alloc (struct objalloc *o, unsigned long original_len)
|
|
Timotheus Pokorra |
70ff62b |
{
|
|
Timotheus Pokorra |
70ff62b |
+ unsigned long len = original_len;
|
|
Timotheus Pokorra |
70ff62b |
/* We avoid confusion from zero sized objects by always allocating
|
|
Timotheus Pokorra |
70ff62b |
at least 1 byte. */
|
|
Timotheus Pokorra |
70ff62b |
if (len == 0)
|
|
Timotheus Pokorra |
70ff62b |
@@ -121,6 +123,11 @@
|
|
Timotheus Pokorra |
70ff62b |
|
|
Timotheus Pokorra |
70ff62b |
len = (len + OBJALLOC_ALIGN - 1) &~ (OBJALLOC_ALIGN - 1);
|
|
Timotheus Pokorra |
70ff62b |
|
|
Timotheus Pokorra |
70ff62b |
+ /* Check for overflow in the alignment operation above and the
|
|
Timotheus Pokorra |
70ff62b |
+ malloc argument below. */
|
|
Timotheus Pokorra |
70ff62b |
+ if (len + CHUNK_HEADER_SIZE < original_len)
|
|
Timotheus Pokorra |
70ff62b |
+ return NULL;
|
|
Timotheus Pokorra |
70ff62b |
+
|
|
Timotheus Pokorra |
70ff62b |
if (len <= o->current_space)
|
|
Timotheus Pokorra |
70ff62b |
{
|
|
Timotheus Pokorra |
70ff62b |
o->current_ptr += len;
|