2 * Copyright (c) 2006 Bruce M. Simpson
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * Regression test for uiomove in kernel; specifically for PR kern/38495.
33 #include <sys/types.h>
34 #include <sys/socket.h>
45 static char socket_path[] = "tmp.XXXXXX";
47 static jmp_buf myjmpbuf;
49 static void handle_sigalrm(int signo __unused)
57 struct sockaddr_un un;
61 if (mkstemp(socket_path) == -1)
63 s = socket(PF_LOCAL, SOCK_DGRAM, 0);
66 memset(&un, 0, sizeof(un));
67 un.sun_family = AF_LOCAL;
69 strcpy(un.sun_path, socket_path);
70 if (bind(s, (struct sockaddr *)&un, sizeof(un)) == -1)
77 char buf[] = "AAAAAAAAA";
80 conn = socket(AF_LOCAL, SOCK_DGRAM, 0);
83 if (sendto(conn, buf, sizeof(buf), 0, (struct sockaddr *)&un,
84 sizeof(un)) != sizeof(buf))
92 /* Make sure the data is there when we try to receive it. */
93 if (recvfrom(s, (void *)-1, 1, 0, NULL, NULL) != -1)
94 errx(-1,"recvfrom succeeded when failure expected");
96 (void)signal(SIGALRM, handle_sigalrm);
97 if (setjmp(myjmpbuf) == 0) {
99 * This recvfrom will panic an unpatched system, and block
103 (void)recvfrom(s, (void *)-1, 1, 0, NULL, NULL);
106 /* We should reach here via longjmp() and all should be well. */