summaryrefslogtreecommitdiffstats
path: root/src/msgb.c
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2019-04-12 21:48:07 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2019-04-12 21:48:11 +0700
commit4f619c202c67dd68b1c3a13d40ad50fa2a6e582d (patch)
treefb2bced9a093aa8bbab94aeebc1e1e7de4bfbd37 /src/msgb.c
parentb480b74192a7c00c4ea077286b921b96e42efabc (diff)
Fix incorrect buffer size calculation
Calling sizeof() on a pointer to dynamically allocated memory would result in getting size of the pointer (usually 4 or 8 bytes) itself, but not the size of allocated memory. Change-Id: I8ffda4dea2b7f9b4b76dfeecad1fab6384c5a62c Fixes: CID#197629, CID#197628, CID#197627 Fixes: CID#197626, CID#197625, CID#197624
Diffstat (limited to 'src/msgb.c')
-rw-r--r--src/msgb.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/msgb.c b/src/msgb.c
index 5a154e56..940135f6 100644
--- a/src/msgb.c
+++ b/src/msgb.c
@@ -522,10 +522,11 @@ const char *msgb_hexdump(const struct msgb *msg)
*/
char *msgb_hexdump_c(const void *ctx, const struct msgb *msg)
{
- char *buf = talloc_size(ctx, msgb_length(msg)*3 + 100);
+ size_t buf_len = msgb_length(msg) * 3 + 100;
+ char *buf = talloc_size(ctx, buf_len);
if (!buf)
return NULL;
- return msgb_hexdump_buf(buf, sizeof(buf), msg);
+ return msgb_hexdump_buf(buf, buf_len, msg);
}
/*! Print a string to the end of message buffer.