Module: kamailio
Branch: master
Commit: d56b96f79c21c23957051eee1b6f7aa22cb075f1
URL:
https://github.com/kamailio/kamailio/commit/d56b96f79c21c23957051eee1b6f7aa…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-11-10T07:58:24+01:00
core: mem - qm check for alignment of main block structure
---
Modified: src/core/mem/q_malloc.c
---
Diff:
https://github.com/kamailio/kamailio/commit/d56b96f79c21c23957051eee1b6f7aa…
Patch:
https://github.com/kamailio/kamailio/commit/d56b96f79c21c23957051eee1b6f7aa…
---
diff --git a/src/core/mem/q_malloc.c b/src/core/mem/q_malloc.c
index ce01af2dfcf..45e15a8a2e9 100644
--- a/src/core/mem/q_malloc.c
+++ b/src/core/mem/q_malloc.c
@@ -198,20 +198,28 @@ struct qm_block *qm_malloc_init(char *address, unsigned long size,
int type)
if((sizeof(struct qm_frag) % ROUNDTO != 0)
|| (sizeof(struct qm_frag_end) % ROUNDTO != 0)) {
- LM_ERR("memory align constraints failure (%lu %% %lu = %lu ::: %lu %% "
+ LM_ERR("memory fragment align constraints failure (%lu %% %lu = %lu "
+ "::: %lu %% "
"%lu = %lu)\n",
sizeof(struct qm_frag), ROUNDTO,
sizeof(struct qm_frag) % ROUNDTO, sizeof(struct qm_frag_end),
ROUNDTO, sizeof(struct qm_frag_end) % ROUNDTO);
return 0;
}
-
+ if(sizeof(struct qm_block) % ROUNDTO != 0) {
+ LM_ERR("memory block align constraints failure (%lu %% %lu = %lu)\n",
+ sizeof(struct qm_block), ROUNDTO,
+ sizeof(struct qm_block) % ROUNDTO);
+ return 0;
+ }
/* make address and size multiple of ROUNDTO */
start = (char *)ROUNDUP((unsigned long)address);
LM_DBG("QM_OPTIMIZE=%lu, QM_OPTIMIZE/ROUNDTO=%lu, ROUNDTO=%lu\n",
QM_MALLOC_OPTIMIZE, QM_MALLOC_OPTIMIZE / ROUNDTO, ROUNDTO);
- LM_DBG("QM_HASH_SIZE=%lu, qm_block size=%lu\n", QM_HASH_SIZE,
- (unsigned long)sizeof(struct qm_block));
+ LM_DBG("QM_HASH_SIZE=%lu, qm_block_size=%lu, qm_block_size %% "
+ "ROUNDTO=%lu\n",
+ QM_HASH_SIZE, (unsigned long)sizeof(struct qm_block),
+ (unsigned long)sizeof(struct qm_block) % ROUNDTO);
LM_DBG("qm_malloc_init(%p, %lu), start=%p\n", address, (unsigned long)size,
start);
if(size < start - address)