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 | 69 |
2 files changed, 0 insertions, 74 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 e67e6adfb8..0000000000 --- a/src/regress/lib/libc/strnlen/strnlentest.c +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
1 | /* $OpenBSD: strnlentest.c,v 1.1 2010/06/02 12:20:47 millert Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 2010 Todd C. Miller <Todd.Miller@courtesan.com> | ||
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 | /* Enable malloc security options. */ | ||
33 | setenv("MALLOC_OPTIONS", "S", 0); | ||
34 | |||
35 | bufsize = getpagesize(); /* trigger guard pages easily */ | ||
36 | buf = malloc(bufsize); | ||
37 | if (buf == NULL) { | ||
38 | fprintf(stderr, "unable to allocate memory\n"); | ||
39 | return 1; | ||
40 | } | ||
41 | memset(buf, 'a', bufsize); | ||
42 | |||
43 | len = strnlen(buf, bufsize); | ||
44 | if (len != bufsize) { | ||
45 | fprintf(stderr, "strnlen: failed unterminated buffer test (1)"); | ||
46 | failures++; | ||
47 | } | ||
48 | |||
49 | len = strnlen(buf, bufsize / 2); | ||
50 | if (len != bufsize / 2) { | ||
51 | fprintf(stderr, "strnlen: failed unterminated buffer test (2)"); | ||
52 | failures++; | ||
53 | } | ||
54 | |||
55 | buf[bufsize - 1] = '\0'; | ||
56 | len = strnlen(buf, bufsize); | ||
57 | if (len != bufsize - 1) { | ||
58 | fprintf(stderr, "strnlen: failed NUL-terminated buffer test (1)"); | ||
59 | failures++; | ||
60 | } | ||
61 | |||
62 | len = strnlen(buf, (size_t)-1); | ||
63 | if (len != bufsize - 1) { | ||
64 | fprintf(stderr, "strnlen: failed NUL-terminated buffer test (2)"); | ||
65 | failures++; | ||
66 | } | ||
67 | |||
68 | return failures; | ||
69 | } | ||