Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/modules Avoid undefined behavior in disabledstat
details: https://anonhg.NetBSD.org/src/rev/b05543dec4ad
branches: trunk
changeset: 745035:b05543dec4ad
user: kamil <kamil%NetBSD.org@localhost>
date: Sat Feb 22 00:18:55 2020 +0000
description:
Avoid undefined behavior in disabledstat
t_builtin.c:174:16, member access within misaligned address 0x741271c25004
for type 'struct modstat_t'
t_builtin.c:175:4, member access within misaligned address 0x741271c251c4
for type 'struct modstat_t'
diffstat:
tests/modules/t_builtin.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diffs (29 lines):
diff -r 7690d5c4c17f -r b05543dec4ad tests/modules/t_builtin.c
--- a/tests/modules/t_builtin.c Sat Feb 22 00:17:54 2020 +0000
+++ b/tests/modules/t_builtin.c Sat Feb 22 00:18:55 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_builtin.c,v 1.4 2019/01/27 02:08:50 pgoyette Exp $ */
+/* $NetBSD: t_builtin.c,v 1.5 2020/02/22 00:18:55 kamil Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc. All rights reserved.
@@ -140,6 +140,7 @@
ATF_TC_BODY(disabledstat, tc)
{
modstat_t *ms;
+ modstat_t m;
struct iovec iov;
size_t len;
int count;
@@ -171,8 +172,9 @@
count = *(int *)iov.iov_base;
ms = (modstat_t *)((char *)iov.iov_base + sizeof(int));
while ( count ) {
- if (strcmp(ms->ms_name, kernfs) == 0) {
- ATF_REQUIRE_EQ(ms->ms_refcnt, (u_int)-1);
+ memcpy(&m, ms, sizeof(m));
+ if (strcmp(m.ms_name, kernfs) == 0) {
+ ATF_REQUIRE_EQ(m.ms_refcnt, (u_int)-1);
found = true;
break;
}
Home |
Main Index |
Thread Index |
Old Index