summaryrefslogtreecommitdiff
path: root/src/regress/lib/libc/strnlen/strnlentest.c
diff options
context:
space:
mode:
authorcvs2svn <admin@example.com>2025-04-14 17:32:06 +0000
committercvs2svn <admin@example.com>2025-04-14 17:32:06 +0000
commiteb8dd9dca1228af0cd132f515509051ecfabf6f6 (patch)
treeedb6da6af7e865d488dc1a29309f1e1ec226e603 /src/regress/lib/libc/strnlen/strnlentest.c
parent247f0352e0ed72a4f476db9dc91f4d982bc83eb2 (diff)
downloadopenbsd-tb_20250414.tar.gz
openbsd-tb_20250414.tar.bz2
openbsd-tb_20250414.zip
This commit was manufactured by cvs2git to create tag 'tb_20250414'.tb_20250414
Diffstat (limited to 'src/regress/lib/libc/strnlen/strnlentest.c')
-rw-r--r--src/regress/lib/libc/strnlen/strnlentest.c66
1 files changed, 0 insertions, 66 deletions
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
26int 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}