summaryrefslogtreecommitdiff
path: root/sys/dev/ic/an.c
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2003-10-05 01:26:12 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2003-10-05 01:26:12 +0000
commitf755b1cdf567719b055fa403d3671d835bbb44de (patch)
tree5d6453f670789eff3f98baeec9374eb58d4836b4 /sys/dev/ic/an.c
parentbae27586cf51e9e0b5f17048442e82e2f7058222 (diff)
from freebsd: read one word less (for type) and take care of odd sized records
Diffstat (limited to 'sys/dev/ic/an.c')
-rw-r--r--sys/dev/ic/an.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/dev/ic/an.c b/sys/dev/ic/an.c
index f4727c1959f..ab2ea1db922 100644
--- a/sys/dev/ic/an.c
+++ b/sys/dev/ic/an.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: an.c,v 1.32 2003/09/26 01:29:55 mickey Exp $ */
+/* $OpenBSD: an.c,v 1.33 2003/10/05 01:26:11 mickey Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@@ -645,11 +645,14 @@ an_read_record(sc, ltv)
rlen = ltv_data_length;
/* Now read the data. */
+ len -= 2; rlen -= 2; /* skip the type */
ptr = ltv->an_val;
- for (i = 0; i < rlen; i += 2)
+ for (i = 0; (rlen - i) > 1; i += 2)
*ptr++ = CSR_READ_2(sc, AN_DATA1);
- for (; i < len; i += 2)
- v = CSR_READ_2(sc, AN_DATA1);
+ if (rlen - i == 1)
+ *(u_int8_t *)ptr = CSR_READ_1(sc, AN_DATA1);
+ for (; i < len; i++)
+ v = CSR_READ_1(sc, AN_DATA1);
#if BYTE_ORDER == BIG_ENDIAN
switch (ltv->an_type) {