From fc4828cdbed3f8d6cef8d02239f8603d789ac099 Mon Sep 17 00:00:00 2001 From: Vratko Polak Date: Tue, 2 Jul 2019 11:07:24 +0200 Subject: api: remove garbage from sockclnt_create reply The fix uses memset to zero after alloc, as sizing of source string is not obvious. Function vl_msg_api_alloc_zero is added (and used), so similar bugs can be fixed easily. Type: fix Ticket: VPP-1716 Change-Id: I3b20040d0de4222686c58779f2c0af78c5543504 Signed-off-by: Vratko Polak --- src/vlibmemory/memory_shared.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/vlibmemory/memory_shared.c') diff --git a/src/vlibmemory/memory_shared.c b/src/vlibmemory/memory_shared.c index 703db9da4ec..fa9936982ee 100644 --- a/src/vlibmemory/memory_shared.c +++ b/src/vlibmemory/memory_shared.c @@ -208,6 +208,16 @@ vl_msg_api_alloc (int nbytes) return vl_msg_api_alloc_internal (nbytes, pool, 0 /* may_return_null */ ); } +void * +vl_msg_api_alloc_zero (int nbytes) +{ + void *ret; + + ret = vl_msg_api_alloc (nbytes); + clib_memset (ret, 0, nbytes); + return ret; +} + void * vl_msg_api_alloc_or_null (int nbytes) { @@ -225,6 +235,16 @@ vl_msg_api_alloc_as_if_client (int nbytes) return vl_msg_api_alloc_internal (nbytes, 0, 0 /* may_return_null */ ); } +void * +vl_msg_api_alloc_zero_as_if_client (int nbytes) +{ + void *ret; + + ret = vl_msg_api_alloc_as_if_client (nbytes); + clib_memset (ret, 0, nbytes); + return ret; +} + void * vl_msg_api_alloc_as_if_client_or_null (int nbytes) { -- cgit 1.2.3-korg