Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb umb(4): Use memcpy, not potentially unaligned/al...
details: https://anonhg.NetBSD.org/src/rev/fff4eb7cb5b7
branches: trunk
changeset: 365289:fff4eb7cb5b7
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Apr 17 13:17:56 2022 +0000
description:
umb(4): Use memcpy, not potentially unaligned/aliased casts.
diffstat:
sys/dev/usb/if_umb.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diffs (37 lines):
diff -r 8b30a28ab5e8 -r fff4eb7cb5b7 sys/dev/usb/if_umb.c
--- a/sys/dev/usb/if_umb.c Sun Apr 17 13:17:40 2022 +0000
+++ b/sys/dev/usb/if_umb.c Sun Apr 17 13:17:56 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_umb.c,v 1.23 2022/04/17 13:17:40 riastradh Exp $ */
+/* $NetBSD: if_umb.c,v 1.24 2022/04/17 13:17:56 riastradh Exp $ */
/* $OpenBSD: if_umb.c,v 1.20 2018/09/10 17:00:45 gerhard Exp $ */
/*
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.23 2022/04/17 13:17:40 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.24 2022/04/17 13:17:56 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1742,7 +1742,8 @@
sin->sin_family = AF_INET;
sin->sin_len = sizeof(ifra.ifra_dstaddr);
off = le32toh(ic->ipv4_gwoffs);
- sin->sin_addr.s_addr = *((uint32_t *)((char *)data + off));
+ memcpy(&sin->sin_addr.s_addr, (const char *)data + off,
+ sizeof(sin->sin_addr.s_addr));
sin = (struct sockaddr_in *)&ifra.ifra_mask;
sin->sin_family = AF_INET;
@@ -1771,7 +1772,7 @@
while (n-- > 0) {
if (off + sizeof(uint32_t) > len)
break;
- val = *((uint32_t *)((char *)data + off));
+ memcpy(&val, (const char *)data + off, sizeof(val));
if (i < UMB_MAX_DNSSRV)
sc->sc_info.ipv4dns[i++] = val;
off += sizeof(uint32_t);
Home |
Main Index |
Thread Index |
Old Index