From 10959cdea2104a6e8c592d590d5b6acf656eb630 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Thu, 8 Mar 2018 21:57:42 +0700 Subject: src/msgb.c: avoid using internal talloc API An internal symbol '_talloc_zero' of talloc library was used during a msgb allocation. This is not actually good because: - it may be removed or modified by talloc developers; - the behaviour may be changed by talloc developers; - it's marked as internal using 'underscore'; - there is public API to do the same. So, let's use the public API. Change-Id: I1080c9071e997944cc0f9fc3716129e9395437ad --- src/msgb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/msgb.c') diff --git a/src/msgb.c b/src/msgb.c index 82902b40..844cfc61 100644 --- a/src/msgb.c +++ b/src/msgb.c @@ -79,14 +79,16 @@ struct msgb *msgb_alloc(uint16_t size, const char *name) { struct msgb *msg; - msg = _talloc_zero(tall_msgb_ctx, sizeof(*msg) + size, name); - + msg = talloc_named_const(tall_msgb_ctx, sizeof(*msg) + size, name); if (!msg) { LOGP(DLGLOBAL, LOGL_FATAL, "Unable to allocate a msgb: " "name='%s', size=%u\n", name, size); return NULL; } + /* Manually zero-initialize allocated memory */ + memset(msg, 0x00, sizeof(*msg) + size); + msg->data_len = size; msg->len = 0; msg->data = msg->_data; -- cgit v1.2.3