cast to the correct message structure (rt_msghdr instead of if_msghdr)

This commit is contained in:
kardel 2023-02-27 13:39:09 +00:00
parent 67db92f955
commit 8f3b9c1ccd
1 changed files with 6 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: grabmyaddr.c,v 1.39 2020/11/25 14:15:41 christos Exp $ */ /* $NetBSD: grabmyaddr.c,v 1.40 2023/02/27 13:39:09 kardel Exp $ */
/* /*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* Copyright (C) 2008 Timo Teras <timo.teras@iki.fi>. * Copyright (C) 2008 Timo Teras <timo.teras@iki.fi>.
@ -849,7 +849,7 @@ kernel_sync()
{ {
caddr_t ref, buf, end; caddr_t ref, buf, end;
size_t bufsiz; size_t bufsiz;
struct if_msghdr *ifm; struct rt_msghdr *rtm;
#define MIBSIZ 6 #define MIBSIZ 6
int mib[MIBSIZ] = { int mib[MIBSIZ] = {
@ -871,8 +871,10 @@ kernel_sync()
if (sysctl(mib, MIBSIZ, buf, &bufsiz, NULL, 0) >= 0) { if (sysctl(mib, MIBSIZ, buf, &bufsiz, NULL, 0) >= 0) {
/* Parse both interfaces and addresses. */ /* Parse both interfaces and addresses. */
for (end = buf + bufsiz; buf < end; buf += ifm->ifm_msglen) { for (end = buf + bufsiz; buf < end; buf += rtm->rtm_msglen) {
ifm = (struct if_msghdr *) buf; rtm = (struct rt_msghdr *) buf;
if (rtm->rtm_version != RTM_VERSION)
continue;
kernel_handle_message(buf); kernel_handle_message(buf);
} }
} else { } else {