Jesse Taube
2025-Feb-28 05:22 UTC
[klibc] [PATCH] ipconfig: align reads of ext for RISC architectures
Some RISC architectures such as Sparc64 will busfault when reading data
from exts if they are not type aligned. Use memcpy to read the data from
exts to ensure type alignment.
A similar issue was fixed in dhcpcd here:
https://github.com/NetworkConfiguration/dhcpcd/issues/430
https://github.com/ColinMcInnes/dhcpcd/commit/07a5fdd7d34b072e52c316877d14c6d2581cb379
Signed-off-by: Jesse Taube <mr.bossman075 at gmail.com>
---
usr/kinit/ipconfig/dhcp_proto.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/usr/kinit/ipconfig/dhcp_proto.c b/usr/kinit/ipconfig/dhcp_proto.c
index 4e560b84..2b83de45 100644
--- a/usr/kinit/ipconfig/dhcp_proto.c
+++ b/usr/kinit/ipconfig/dhcp_proto.c
@@ -112,8 +112,11 @@ static int dhcp_parse(struct netdev *dev, struct bootp_hdr
*hdr,
break;
switch (opt) {
case 51: /* IP Address Lease Time */
- if (len == 4)
- leasetime = ntohl(*(uint32_t *)ext);
+ if (len == 4) {
+ /* Sparc64 needs ext reads to be type aligned */
+ memcpy(&leasetime, ext, 4);
+ leasetime = ntohl(leasetime);
+ }
break;
case 53: /* DHCP Message Type */
if (len == 1)
--
2.47.2