patches/glibc/2.1.3/rh62-11-glibc-2.1.3-calloc.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue May 08 17:48:32 2007 +0000 (2007-05-08)
changeset 78 c3868084d81a
permissions -rw-r--r--
Huge fixes to glibc build, so that we can build at least (and at last):
- use ports addon even when installing headers,
- use optimisation (-O) when installing headers, to avoid unnecessary warnings (thanks Robert P. J. DAY for pointing this out!),
- lowest kernel version to use is only X.Y.Z, not X.Y.Z.T,
- a bit of preparations for NPTL (RSN I hope),
- fix fixing the linker scripts (changing the backup file is kind of useless and stupid);

Shut uClibc finish step: there really is nothing to do;

Add a patch for glibc-2.3.6 weak aliases handling on some archs (ARM and ALPHA at least);

Did not catch the make errors: fixed the pattern matching in scripts/functions;

Introduce a new log level, ALL:
- send components' build messages there,
- DEBUG log level is destined only for crosstool-NG debug messages,
- migrate sub-actions to use appropriate log levels;

Update the armeb-unknown-linux-gnu sample:
- it builds!
- uses gcc-4.0.4 and glibc-2.3.6,
- updated to latest config options set.
yann@1
     1
diff -ur glibc-2.1.3.orig/malloc/malloc.c glibc-2.1.3/malloc/malloc.c
yann@1
     2
--- glibc-2.1.3.orig/malloc/malloc.c	Wed Feb 23 10:02:55 2000
yann@1
     3
+++ glibc-2.1.3/malloc/malloc.c	Thu Aug  1 09:24:10 2002
yann@1
     4
@@ -3656,12 +3656,20 @@
yann@1
     5
 {
yann@1
     6
   arena *ar_ptr;
yann@1
     7
   mchunkptr p, oldtop;
yann@1
     8
-  INTERNAL_SIZE_T sz, csz, oldtopsize;
yann@1
     9
+  INTERNAL_SIZE_T bytes, sz, csz, oldtopsize;
yann@1
    10
   Void_t* mem;
yann@1
    11
 
yann@1
    12
+  /* size_t is unsigned so the behavior on overflow is defined;
yann@1
    13
+   * request2size() uses similar post-checks anyway. */
yann@1
    14
+  bytes = n * elem_size;
yann@1
    15
+  if ((n | elem_size) >= 65536 && elem_size && bytes / elem_size != n) {
yann@1
    16
+    __set_errno (ENOMEM);
yann@1
    17
+    return 0;
yann@1
    18
+  }
yann@1
    19
+
yann@1
    20
 #if defined _LIBC || defined MALLOC_HOOKS
yann@1
    21
   if (__malloc_hook != NULL) {
yann@1
    22
-    sz = n * elem_size;
yann@1
    23
+    sz = bytes;
yann@1
    24
 #if defined __GNUC__ && __GNUC__ >= 2
yann@1
    25
     mem = (*__malloc_hook)(sz, __builtin_return_address (0));
yann@1
    26
 #else
yann@1
    27
@@ -3678,7 +3686,7 @@
yann@1
    28
   }
yann@1
    29
 #endif
yann@1
    30
 
yann@1
    31
-  if(request2size(n * elem_size, sz))
yann@1
    32
+  if(request2size(bytes, sz))
yann@1
    33
     return 0;
yann@1
    34
   arena_get(ar_ptr, sz);
yann@1
    35
   if(!ar_ptr)