diff mbox series

unit: correct memcpy overrun in test-dpp

Message ID 20231025224224.321013-1-prestwoj@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series unit: correct memcpy overrun in test-dpp | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint success GitLint
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-makedistcheck success Make Distcheck
prestwoj/iwd-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-makedistcheck success Make Distcheck
prestwoj/iwd-alpine-ci-incremental_build success Incremental build not run PASS
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-testrunner success test-runner PASS

Commit Message

James Prestwood Oct. 25, 2023, 10:42 p.m. UTC
The memcpy in HEX2BUF was copying the length of the buffer that was
passed in, not the actual length of the converted hexstring. This
test was segfaulting in the Alpine CI which uses clang/musl.
---
 unit/test-dpp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Denis Kenzior Oct. 26, 2023, 2:33 p.m. UTC | #1
Hi James,

On 10/25/23 17:42, James Prestwood wrote:
> The memcpy in HEX2BUF was copying the length of the buffer that was
> passed in, not the actual length of the converted hexstring. This
> test was segfaulting in the Alpine CI which uses clang/musl.
> ---
>   unit/test-dpp.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 

Applied, thanks.

Regards,
-Denis
diff mbox series

Patch

diff --git a/unit/test-dpp.c b/unit/test-dpp.c
index c782efba..c3f3731f 100644
--- a/unit/test-dpp.c
+++ b/unit/test-dpp.c
@@ -183,8 +183,9 @@  const char *r_asn1 = "3039301306072a8648ce3d020106082a8648ce3d0301070322000209c5
 			"4df9fd25a045201885c39cc5cfae397ddaeda957dec57fa0e3503f";
 
 #define HEX2BUF(s, buf, _len) { \
-	unsigned char *_tmp = l_util_from_hexstring(s, NULL); \
-	memcpy(buf, _tmp, _len); \
+	size_t _len_out; \
+	unsigned char *_tmp = l_util_from_hexstring(s, &_len_out); \
+	memcpy(buf, _tmp, _len_out); \
 	l_free(_tmp); \
 }