diff options
Diffstat (limited to 'src/regress/lib/libc/strnlen')
| -rw-r--r-- | src/regress/lib/libc/strnlen/Makefile | 5 | ||||
| -rw-r--r-- | src/regress/lib/libc/strnlen/strnlentest.c | 66 |
2 files changed, 0 insertions, 71 deletions
diff --git a/src/regress/lib/libc/strnlen/Makefile b/src/regress/lib/libc/strnlen/Makefile deleted file mode 100644 index e7c74972e1..0000000000 --- a/src/regress/lib/libc/strnlen/Makefile +++ /dev/null | |||
| @@ -1,5 +0,0 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.1 2010/06/02 12:20:47 millert Exp $ | ||
| 2 | |||
| 3 | PROG= strnlentest | ||
| 4 | |||
| 5 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libc/strnlen/strnlentest.c b/src/regress/lib/libc/strnlen/strnlentest.c deleted file mode 100644 index 78f8cfb252..0000000000 --- a/src/regress/lib/libc/strnlen/strnlentest.c +++ /dev/null | |||
| @@ -1,66 +0,0 @@ | |||
| 1 | /* $OpenBSD: strnlentest.c,v 1.3 2021/09/01 09:26:32 jasper Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 2010 Todd C. Miller <millert@openbsd.org> | ||
| 5 | * | ||
| 6 | * Permission to use, copy, modify, and distribute this software for any | ||
| 7 | * purpose with or without fee is hereby granted, provided that the above | ||
| 8 | * copyright notice and this permission notice appear in all copies. | ||
| 9 | * | ||
| 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include <sys/types.h> | ||
| 20 | |||
| 21 | #include <stdio.h> | ||
| 22 | #include <stdlib.h> | ||
| 23 | #include <string.h> | ||
| 24 | #include <unistd.h> | ||
| 25 | |||
| 26 | int main(int argc, char *argv[]) | ||
| 27 | { | ||
| 28 | char *buf; | ||
| 29 | int failures = 0; | ||
| 30 | size_t len, bufsize; | ||
| 31 | |||
| 32 | bufsize = getpagesize(); /* trigger guard pages easily */ | ||
| 33 | buf = malloc(bufsize); | ||
| 34 | if (buf == NULL) { | ||
| 35 | fprintf(stderr, "unable to allocate memory\n"); | ||
| 36 | return 1; | ||
| 37 | } | ||
| 38 | memset(buf, 'a', bufsize); | ||
| 39 | |||
| 40 | len = strnlen(buf, bufsize); | ||
| 41 | if (len != bufsize) { | ||
| 42 | fprintf(stderr, "strnlen: failed unterminated buffer test (1)"); | ||
| 43 | failures++; | ||
| 44 | } | ||
| 45 | |||
| 46 | len = strnlen(buf, bufsize / 2); | ||
| 47 | if (len != bufsize / 2) { | ||
| 48 | fprintf(stderr, "strnlen: failed unterminated buffer test (2)"); | ||
| 49 | failures++; | ||
| 50 | } | ||
| 51 | |||
| 52 | buf[bufsize - 1] = '\0'; | ||
| 53 | len = strnlen(buf, bufsize); | ||
| 54 | if (len != bufsize - 1) { | ||
| 55 | fprintf(stderr, "strnlen: failed NUL-terminated buffer test (1)"); | ||
| 56 | failures++; | ||
| 57 | } | ||
| 58 | |||
| 59 | len = strnlen(buf, (size_t)-1); | ||
| 60 | if (len != bufsize - 1) { | ||
| 61 | fprintf(stderr, "strnlen: failed NUL-terminated buffer test (2)"); | ||
| 62 | failures++; | ||
| 63 | } | ||
| 64 | |||
| 65 | return failures; | ||
| 66 | } | ||
