diff options
author | 2018-10-16 16:54:18 +0000 | |
---|---|---|
committer | 2018-10-16 16:54:18 +0000 | |
commit | bb03833f977b47ef5cb4fb94287bc4b3ccb3752f (patch) | |
tree | 152ee0f2106dc7a31e721bea711c8110d1b4a55f | |
parent | Add gapdummy logic (already used on other archs) to allow linking with lld. (diff) | |
download | wireguard-openbsd-bb03833f977b47ef5cb4fb94287bc4b3ccb3752f.tar.xz wireguard-openbsd-bb03833f977b47ef5cb4fb94287bc4b3ccb3752f.zip |
Add a test covering the recently fixed fcntl() panic.
While here, make the verbose output more verbose and enable warnings.
-rw-r--r-- | regress/sys/kern/flock/Makefile | 6 | ||||
-rw-r--r-- | regress/sys/kern/flock/flock.c | 40 |
2 files changed, 43 insertions, 3 deletions
diff --git a/regress/sys/kern/flock/Makefile b/regress/sys/kern/flock/Makefile index 1d259d43ea1..0f4fbc6a090 100644 --- a/regress/sys/kern/flock/Makefile +++ b/regress/sys/kern/flock/Makefile @@ -1,8 +1,10 @@ -# $OpenBSD: Makefile,v 1.3 2011/07/07 01:38:53 guenther Exp $ +# $OpenBSD: Makefile,v 1.4 2018/10/16 16:54:18 anton Exp $ PROG= flock -TESTS!=jot 15 1 +WARNINGS= yes + +TESTS!=jot 16 1 # XXX known failures (talk to art) REGRESS_SKIP_TARGETS = t-5 t-6 diff --git a/regress/sys/kern/flock/flock.c b/regress/sys/kern/flock/flock.c index b6606743fc6..6617adb07b3 100644 --- a/regress/sys/kern/flock/flock.c +++ b/regress/sys/kern/flock/flock.c @@ -131,7 +131,8 @@ safe_kill(pid_t pid, int sig) #define FAIL(test) \ do { \ if (test) { \ - if (verbose) printf("FAIL (%s)\n", #test); \ + if (verbose) printf("%s: %d: FAIL (%s)\n", \ + __func__, __LINE__, #test); \ return -1; \ } \ } while (0) @@ -1412,6 +1413,42 @@ test15(int fd, __unused int argc, const __unused char **argv) #endif } +/* + * Test 16 - double free regression + */ +static int +test16(int fd, __unused int argc, const __unused char **argv) +{ + struct flock fl; + int res; + + fl.l_pid = 0; + fl.l_type = 1; + fl.l_whence = 0; + + fl.l_start = 0; + fl.l_len = 0x8000000000000000; + res = fcntl(fd, F_SETLK, &fl); + FAIL(res != 0); + + fl.l_start = 0x10000; + fl.l_len = 0; + res = fcntl(fd, F_SETLK, &fl); + FAIL(res != 0); + + fl.l_start = 0; + fl.l_len = 0x8000000000000000; + res = fcntl(fd, F_SETLK, &fl); + FAIL(res != 0); + + fl.l_start = 0x10000; + fl.l_len = 0; + res = fcntl(fd, F_SETLK, &fl); + FAIL(res != 0); + + SUCCEED; +} + struct test { int (*testfn)(int, int, const char **); /* function to perform the test */ int num; /* test number */ @@ -1434,6 +1471,7 @@ struct test tests[] = { { test13, 13, 1 }, { test14, 14, 0 }, { test15, 15, 1 }, + { test16, 16, 0 }, }; int test_count = sizeof(tests) / sizeof(tests[0]); |