summaryrefslogtreecommitdiffstats
path: root/usr.sbin/rpki-client
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2020-04-16 14:39:44 +0000
committerclaudio <claudio@openbsd.org>2020-04-16 14:39:44 +0000
commitfac5751d5b2b42da8477559003f44c2afe06e31b (patch)
tree6f1433fd561c0e6370f9b6c132dfd26110513604 /usr.sbin/rpki-client
parentMove the UTF-8 flag to terminal flags. (diff)
downloadwireguard-openbsd-fac5751d5b2b42da8477559003f44c2afe06e31b.tar.xz
wireguard-openbsd-fac5751d5b2b42da8477559003f44c2afe06e31b.zip
It is unclear why data is memcpy-ed into a char buf[2] that is used as
argument to ntohs(). Just memcpy to a uint16_t value and ntohs this value. Fixes possible alignment issues as reported by newer gcc compilers. OK beck@
Diffstat (limited to 'usr.sbin/rpki-client')
-rw-r--r--usr.sbin/rpki-client/ip.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/usr.sbin/rpki-client/ip.c b/usr.sbin/rpki-client/ip.c
index ad1fad59e55..c0af1ed23b5 100644
--- a/usr.sbin/rpki-client/ip.c
+++ b/usr.sbin/rpki-client/ip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip.c,v 1.11 2020/04/16 11:27:49 claudio Exp $ */
+/* $OpenBSD: ip.c,v 1.12 2020/04/16 14:39:44 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -41,8 +41,7 @@
int
ip_addr_afi_parse(const char *fn, const ASN1_OCTET_STRING *p, enum afi *afi)
{
- char buf[2];
- short v;
+ uint16_t v;
if (p->length == 0 || p->length > 3) {
warnx("%s: invalid field length, want 1--3, have %d",
@@ -50,8 +49,8 @@ ip_addr_afi_parse(const char *fn, const ASN1_OCTET_STRING *p, enum afi *afi)
return 0;
}
- memcpy(buf, p->data, sizeof(uint16_t));
- v = ntohs(*(uint16_t *)buf);
+ memcpy(&v, p->data, sizeof(v));
+ v = ntohs(v);
/* Only accept IPv4 and IPv6 AFIs. */