|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
From fed42742e0b33b358610bf62c7474f55e6465205 Mon Sep 17 00:00:00 2001
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
From: Chet Ramey <chet.ramey@case.edu>
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
Date: Wed, 17 Nov 2021 16:44:19 -0500
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
Subject: [PATCH] Bash-5.1 patch 9: fix bash malloc implementation of
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
malloc_usable_size
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
---
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
lib/malloc/malloc.c | 13 ++++++-------
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
patchlevel.h | 2 +-
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
2 files changed, 7 insertions(+), 8 deletions(-)
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
diff --git a/lib/malloc/malloc.c b/lib/malloc/malloc.c
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
index 439f8ef1..92e6efa5 100644
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
--- a/lib/malloc/malloc.c
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
+++ b/lib/malloc/malloc.c
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
@@ -1286,13 +1286,12 @@ malloc_usable_size (mem)
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
p = (union mhead *) ap - 1;
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
}
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
- /* XXX - should we return 0 if ISFREE? */
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
- maxbytes = binsize(p->mh_index);
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
-
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
- /* So the usable size is the maximum number of bytes in the bin less the
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
- malloc overhead */
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
- maxbytes -= MOVERHEAD + MSLOP;
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
- return (maxbytes);
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
+ /* return 0 if ISFREE */
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
+ if (p->mh_alloc == ISFREE)
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
+ return 0;
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
+
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
+ /* Since we use bounds checking, the usable size is the last requested size. */
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
+ return (p->mh_nbytes);
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
}
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
#if !defined (NO_VALLOC)
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
diff --git a/patchlevel.h b/patchlevel.h
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
index 10fde2ee..17586ff7 100644
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
--- a/patchlevel.h
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
+++ b/patchlevel.h
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
@@ -25,6 +25,6 @@
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
looks for to find the patch level (for the sccs version string). */
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
-#define PATCHLEVEL 8
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
+#define PATCHLEVEL 9
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
#endif /* _PATCHLEVEL_H_ */
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
--
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
2.31.1
|
|
![](https://seccdn.libravatar.org/avatar/186c360ce12880edb24f229f9f386ae1b1b09d5dd5446932c3a2c03e108469e6?s=16&d=retro) |
667315b |
|