1 /* $NetBSD: t_compat.c,v 1.1 2010/11/07 19:53:42 pooka Exp $ */
3 #include <sys/socket.h>
6 #include <netinet/in.h>
12 #include <rump/rump.h>
13 #include <rump/rump_syscalls.h>
15 #include "../config/netconfig.c"
18 * Test for stack smashing in compat ioctl handling. Adapted as an
19 * atf test from code provided by Onno van der Linden in PR kern/44054
23 char ifr_name
[IFNAMSIZ
]; /* if name, e.g. "en0" */
25 struct sockaddr ifru_addr
;
26 struct sockaddr ifru_dstaddr
;
27 struct sockaddr ifru_broadaddr
;
40 #define OOSIOCGIFBRDADDR _IOWR('i', 18, struct oifreq)
42 ATF_TC(OOSIOCGIFBRDADDR
);
43 ATF_TC_HEAD(OOSIOCGIFBRDADDR
, tc
)
46 atf_tc_set_md_var(tc
, "descr", "Checks that OOSIOCGIFBRDADDR works "
50 ATF_TC_BODY(OOSIOCGIFBRDADDR
, tc
)
54 struct sockaddr_in
*sin
;
57 memset(&ifreq
,'\0',sizeof ifreq
);
61 /* create an interface and give it netmask 0xffff0000 */
62 rv
= rump_pub_shmif_create("bus", &ifnum
);
64 atf_tc_fail("failed to create shmif: %s", strerror(rv
));
65 sprintf(ifreq
.ifr_name
, "shmif%d", ifnum
);
66 netcfg_rump_if(ifreq
.ifr_name
, "1.7.64.10", "255.255.0.0");
68 /* query kernel for iface bcast */
69 RL(fd
= rump_sys_socket(AF_INET
, SOCK_DGRAM
, 0));
70 RL(rump_sys_ioctl(fd
, OOSIOCGIFBRDADDR
, &ifreq
));
72 /* make sure we got what we deserve */
73 sin
= (struct sockaddr_in
*)&ifreq
.ifr_broadaddr
;
74 ATF_REQUIRE_EQ(sin
->sin_addr
.s_addr
, htonl(0x0107ffff));
81 ATF_TP_ADD_TC(tp
, OOSIOCGIFBRDADDR
);
82 return atf_no_error();