Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/bootp/common Avoid access to unaligned data.
details: https://anonhg.NetBSD.org/src/rev/2772d0d62d30
branches: trunk
changeset: 350429:2772d0d62d30
user: joerg <joerg%NetBSD.org@localhost>
date: Wed Jan 11 12:18:22 2017 +0000
description:
Avoid access to unaligned data.
diffstat:
usr.sbin/bootp/common/readfile.c | 23 ++++++++---------------
1 files changed, 8 insertions(+), 15 deletions(-)
diffs (57 lines):
diff -r 823c10461ec3 -r 2772d0d62d30 usr.sbin/bootp/common/readfile.c
--- a/usr.sbin/bootp/common/readfile.c Wed Jan 11 12:17:34 2017 +0000
+++ b/usr.sbin/bootp/common/readfile.c Wed Jan 11 12:18:22 2017 +0000
@@ -22,7 +22,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: readfile.c,v 1.19 2011/10/07 10:06:39 joerg Exp $");
+__RCSID("$NetBSD: readfile.c,v 1.20 2017/01/11 12:18:22 joerg Exp $");
#endif
@@ -1582,23 +1582,21 @@
PRIVATE struct in_addr_list *
get_addresses(char **src)
{
- struct in_addr tmpaddrlist[MAXINADDRS];
- struct in_addr *address1, *address2;
+ __aligned(4) struct in_addr tmpaddrlist[MAXINADDRS];
struct in_addr_list *result;
- unsigned addrcount, totalsize;
+ unsigned addrcount, totalsize, address;
- address1 = tmpaddrlist;
- for (addrcount = 0; addrcount < MAXINADDRS; addrcount++) {
+ for (address = 0, addrcount = 0; addrcount < MAXINADDRS; addrcount++) {
while (isspace((unsigned char)**src) || (**src == ',')) {
(*src)++;
}
if (!**src) { /* Quit if nothing more */
break;
}
- if (prs_inetaddr(src, &(address1->s_addr)) < 0) {
+ if (prs_inetaddr(src, &tmpaddrlist[address].s_addr) < 0) {
break;
}
- address1++; /* Point to next address slot */
+ address++; /* Point to next address slot */
}
if (addrcount < 1) {
result = NULL;
@@ -1608,13 +1606,8 @@
result = (struct in_addr_list *) smalloc(totalsize);
result->linkcount = 1;
result->addrcount = addrcount;
- address1 = tmpaddrlist;
- address2 = result->addr;
- for (; addrcount > 0; addrcount--) {
- address2->s_addr = address1->s_addr;
- address1++;
- address2++;
- }
+ for (address = 0; address < addrcount; ++address)
+ result->addr[address] = tmpaddrlist[address];
}
return result;
}
Home |
Main Index |
Thread Index |
Old Index