1*ab8c6b02Santon /* $OpenBSD: open.c,v 1.2 2018/07/30 20:53:42 anton Exp $ */
2520f7349Santon /*
3520f7349Santon * Copyright (c) 2018 Anton Lindqvist <anton@openbsd.org>
4520f7349Santon *
5520f7349Santon * Permission to use, copy, modify, and distribute this software for any
6520f7349Santon * purpose with or without fee is hereby granted, provided that the above
7520f7349Santon * copyright notice and this permission notice appear in all copies.
8520f7349Santon *
9520f7349Santon * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10520f7349Santon * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11520f7349Santon * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12520f7349Santon * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13520f7349Santon * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14520f7349Santon * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15520f7349Santon * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16520f7349Santon */
17520f7349Santon
18520f7349Santon /*
19520f7349Santon * Regression test for NULL-deref inside doopenat().
20520f7349Santon */
21520f7349Santon
22520f7349Santon #include <err.h>
23520f7349Santon #include <fcntl.h>
24520f7349Santon #include <unistd.h>
25520f7349Santon
26520f7349Santon int
main(void)27520f7349Santon main(void)
28520f7349Santon {
29520f7349Santon const char *path = "/dev/bpf";
30*ab8c6b02Santon int fd;
31520f7349Santon
32*ab8c6b02Santon fd = open(path, O_WRONLY | O_TRUNC | O_SHLOCK);
33520f7349Santon if (fd == -1)
34520f7349Santon err(1, "open: %s", path);
35520f7349Santon close(fd);
36520f7349Santon
37520f7349Santon return 0;
38520f7349Santon }
39