From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH] unit: correct memcpy overrun in test-dpp
Date: Wed, 25 Oct 2023 15:42:24 -0700 [thread overview]
Message-ID: <20231025224224.321013-1-prestwoj@gmail.com> (raw)
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(-)
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); \
}
--
2.25.1
next reply other threads:[~2023-10-25 22:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-25 22:42 James Prestwood [this message]
2023-10-26 14:33 ` [PATCH] unit: correct memcpy overrun in test-dpp Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231025224224.321013-1-prestwoj@gmail.com \
--to=prestwoj@gmail.com \
--cc=iwd@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox