summaryrefslogtreecommitdiff
path: root/openbsd-compat/regress/strduptest.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2009-12-29 21:38:40 +0000
committerColin Watson <cjwatson@debian.org>2009-12-29 21:38:40 +0000
commit1b816ea846aca3ee89e7995373ace609e9518424 (patch)
treeb41cdc8495cae7fa9c2e0f98a5f2e71656b61f9a /openbsd-compat/regress/strduptest.c
parentfa585019a79ebcb4e0202b1c33f87ff1c5c9ce1c (diff)
parent086ea76990b1e6287c24b6db74adffd4605eb3b0 (diff)
import openssh-4.6p1-gsskex-20070312.patch
Diffstat (limited to 'openbsd-compat/regress/strduptest.c')
-rw-r--r--openbsd-compat/regress/strduptest.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/openbsd-compat/regress/strduptest.c b/openbsd-compat/regress/strduptest.c
new file mode 100644
index 000000000..7f6d779be
--- /dev/null
+++ b/openbsd-compat/regress/strduptest.c
@@ -0,0 +1,45 @@
1/*
2 * Copyright (c) 2005 Darren Tucker
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#include <stdlib.h>
18#include <string.h>
19
20static int fail = 0;
21
22void
23test(const char *a)
24{
25 char *b;
26
27 b = strdup(a);
28 if (b == 0) {
29 fail = 1;
30 return;
31 }
32 if (strcmp(a, b) != 0)
33 fail = 1;
34 free(b);
35}
36
37int
38main(void)
39{
40 test("");
41 test("a");
42 test("\0");
43 test("abcdefghijklmnopqrstuvwxyz");
44 return fail;
45}