diff mbox series

[1/2] unit: memset band to zero after alloc

Message ID 20220719222950.540619-1-prestwoj@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series [1/2] unit: memset band to zero after alloc | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-gitlint fail [2/2] wiphy: fix strange compiler bug with gcc 11.2 14: B1 Line exceeds max length (134>80): "/usr/include/bits/string_fortified.h:59:10: error: ‘__builtin_memset’ offset [0, 7] is out of the bounds [0, 0] [-Werror=array-bounds]"
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-ci-makedistcheck success Make Distcheck
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-makedistcheck success Make Distcheck
prestwoj/iwd-alpine-ci-build success Build - Configure
prestwoj/iwd-ci-clang success clang PASS
prestwoj/iwd-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-ci-makecheck success Make Check
prestwoj/iwd-alpine-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-alpine-ci-makecheck success Make Check
prestwoj/iwd-ci-incremental_build success Incremental Build with patches
prestwoj/iwd-alpine-ci-incremental_build success Incremental Build with patches
prestwoj/iwd-ci-testrunner success test-runner PASS

Commit Message

James Prestwood July 19, 2022, 10:29 p.m. UTC
In test-band the band object was allocated using l_malloc, but not
memset to zero. This will cause problems if allocated pointers are
included in struct band once band is freed.
---
 unit/test-band.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Denis Kenzior July 19, 2022, 10:45 p.m. UTC | #1
Hi James,

On 7/19/22 17:29, James Prestwood wrote:
> In test-band the band object was allocated using l_malloc, but not
> memset to zero. This will cause problems if allocated pointers are
> included in struct band once band is freed.
> ---
>   unit/test-band.c | 2 ++
>   1 file changed, 2 insertions(+)
> 

Both applied, thanks.

Regards,
-Denis
diff mbox series

Patch

diff --git a/unit/test-band.c b/unit/test-band.c
index 757db377..0dd9b67b 100644
--- a/unit/test-band.c
+++ b/unit/test-band.c
@@ -52,6 +52,8 @@  static struct band *new_band()
 	/* band + 8 basic rates */
 	struct band *band = l_malloc(sizeof(struct band) + 8);
 
+	memset(band, 0, sizeof(struct band) + 8);
+
 	band->supported_rates_len = 8;
 	band->supported_rates[0] = 12;
 	band->supported_rates[1] = 18;