wrowe 2004/03/16 20:26:06
Modified: misc Tag: APU_0_9_BRANCH apr_rmm.c
test Tag: APU_0_9_BRANCH testrmm.c
Log:
Backport fix of apr_rmm.c 1.23 by Ahab A. <eabouzou yahoo.com> to avoid
an underflow caused by a signedness mismatch.
Test by Philip M Chiasson <gozer apache.org>
Reviewed by: wrowe, gozer, Geoffrey Young
PR: 25550
Revision Changes Path
No revision
No revision
1.20.2.3 +1 -1 apr-util/misc/apr_rmm.c
Index: apr_rmm.c
===================================================================
RCS file: /home/cvs/apr-util/misc/apr_rmm.c,v
retrieving revision 1.20.2.2
retrieving revision 1.20.2.3
diff -u -r1.20.2.2 -r1.20.2.3
--- apr_rmm.c 13 Feb 2004 09:52:43 -0000 1.20.2.2
+++ apr_rmm.c 17 Mar 2004 04:26:06 -0000 1.20.2.3
@@ -87,7 +87,7 @@
next = blk->next;
}
- if (bestsize - size > sizeof(rmm_block_t)) {
+ if (bestsize > sizeof(rmm_block_t) + size) {
struct rmm_block_t *blk = (rmm_block_t*)((char*)rmm->base + best);
struct rmm_block_t *new = (rmm_block_t*)((char*)rmm->base + best +
size);
No revision
No revision
1.3.2.2 +10 -2 apr-util/test/testrmm.c
Index: testrmm.c
===================================================================
RCS file: /home/cvs/apr-util/test/testrmm.c,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -u -r1.3.2.1 -r1.3.2.2
--- testrmm.c 13 Feb 2004 09:52:44 -0000 1.3.2.1
+++ testrmm.c 17 Mar 2004 04:26:06 -0000 1.3.2.2
@@ -29,7 +29,7 @@
#if APR_HAS_SHARED_MEMORY
-#define FRAG_SIZE 10
+#define FRAG_SIZE 80
#define FRAG_COUNT 10
#define SHARED_SIZE (apr_size_t)(FRAG_SIZE * FRAG_COUNT * sizeof(char*))
@@ -78,7 +78,15 @@
off[i] = apr_rmm_malloc(rmm, fragsize);
}
fprintf(stdout, "OK\n");
-
+
+ printf("Checking for out of memory allocation............");
+ if (apr_rmm_malloc(rmm, FRAG_SIZE * FRAG_COUNT) == 0) {
+ fprintf(stdout, "OK\n");
+ }
+ else {
+ return APR_EGENERAL;
+ }
+
printf("Setting each fragment to a unique value..........");
for (i = 0; i < FRAG_COUNT; i++) {
int j;