summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/lib/libc/ssp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/netbsd-tests/lib/libc/ssp')
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_fgets.c46
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_getcwd.c47
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_gets.c43
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_memcpy.c48
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_memmove.c48
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_memset.c49
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_raw.c57
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_read.c65
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_readlink.c66
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_snprintf.c51
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_sprintf.c43
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_stpcpy.c49
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_stpncpy.c56
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_strcat.c46
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_strcpy.c45
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_strncat.c48
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_strncpy.c47
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_vsnprintf.c57
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_vsprintf.c55
-rwxr-xr-xcontrib/netbsd-tests/lib/libc/ssp/t_ssp.sh459
20 files changed, 1425 insertions, 0 deletions
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_fgets.c b/contrib/netbsd-tests/lib/libc/ssp/h_fgets.c
new file mode 100644
index 0000000..ad9376a
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_fgets.c
@@ -0,0 +1,46 @@
+/* $NetBSD: h_fgets.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+
+/*
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: h_fgets.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ char b[10];
+ int len = atoi(argv[1]);
+ (void)fgets(b, len, stdin);
+ (void)printf("%s\n", b);
+
+ return 0;
+}
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_getcwd.c b/contrib/netbsd-tests/lib/libc/ssp/h_getcwd.c
new file mode 100644
index 0000000..68e3a6f
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_getcwd.c
@@ -0,0 +1,47 @@
+/* $NetBSD: h_getcwd.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+
+/*
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: h_getcwd.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+
+#include <sys/param.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ char b[MAXPATHLEN];
+ size_t len = atoi(argv[1]);
+ (void)getcwd(b, len);
+ (void)printf("%s\n", b);
+ return 0;
+}
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_gets.c b/contrib/netbsd-tests/lib/libc/ssp/h_gets.c
new file mode 100644
index 0000000..8c601b0
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_gets.c
@@ -0,0 +1,43 @@
+/* $NetBSD: h_gets.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+
+/*
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: h_gets.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+
+#include <stdio.h>
+
+int
+main(int argc, char *argv[])
+{
+ char b[10];
+ (void)gets(b);
+ (void)printf("%s\n", b);
+ return 0;
+}
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_memcpy.c b/contrib/netbsd-tests/lib/libc/ssp/h_memcpy.c
new file mode 100644
index 0000000..1950f73
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_memcpy.c
@@ -0,0 +1,48 @@
+/* $NetBSD: h_memcpy.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+
+/*
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: h_memcpy.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ char b[10];
+ int len = atoi(argv[1]);
+
+ (void)memcpy(b, "1020202020202", len);
+ (void)printf("%*.*s\n", len, len, b);
+
+ return 0;
+}
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_memmove.c b/contrib/netbsd-tests/lib/libc/ssp/h_memmove.c
new file mode 100644
index 0000000..0ebfd29
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_memmove.c
@@ -0,0 +1,48 @@
+/* $NetBSD: h_memmove.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+
+/*
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: h_memmove.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ char b[10];
+ int len = atoi(argv[1]);
+
+ (void)memmove(b, "1020202020202", len);
+ (void)printf("%*.*s\n", len, len, b);
+
+ return 0;
+}
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_memset.c b/contrib/netbsd-tests/lib/libc/ssp/h_memset.c
new file mode 100644
index 0000000..c5ab607
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_memset.c
@@ -0,0 +1,49 @@
+/* $NetBSD: h_memset.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+
+/*
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: h_memset.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ char b[10];
+ size_t len = atoi(argv[1]);
+ (void)memset(b, 0, len);
+#ifdef __FreeBSD__
+ return b[0]; /* keeps optimizer from zapping the call to memset() */
+#else
+ return 0;
+#endif
+}
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_raw.c b/contrib/netbsd-tests/lib/libc/ssp/h_raw.c
new file mode 100644
index 0000000..a232481
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_raw.c
@@ -0,0 +1,57 @@
+/* $NetBSD: h_raw.c,v 1.6 2011/07/24 14:00:36 christos Exp $ */
+
+/*
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2011\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: h_raw.c,v 1.6 2011/07/24 14:00:36 christos Exp $");
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void poke(int *, size_t);
+
+void
+poke(int *b, size_t index)
+{
+ size_t i;
+ volatile int sum = 0;
+
+ b[index] = 42;
+ for (i = 0; i < 10; i++)
+ sum += b[i];
+}
+
+int
+main(int argc, char *argv[])
+{
+ int b[10];
+
+ poke(b, atoi(argv[1]));
+ return 0;
+}
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_read.c b/contrib/netbsd-tests/lib/libc/ssp/h_read.c
new file mode 100644
index 0000000..1197b6c
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_read.c
@@ -0,0 +1,65 @@
+/* $NetBSD: h_read.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+
+/*
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: h_read.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+
+#include <sys/param.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#ifdef __FreeBSD__
+#include <fcntl.h>
+
+int
+main(int argc, char *argv[])
+{
+ char b[MAXPATHLEN];
+ int fd, n;
+ size_t len = atoi(argv[1]);
+
+ fd = open("/dev/zero", O_RDONLY);
+ if ((n = read(fd, b, len)) == -1)
+ abort();
+ (void)printf("%s\n", b);
+ return (0);
+}
+#else
+int
+main(int argc, char *argv[])
+{
+ char b[MAXPATHLEN];
+ size_t len = atoi(argv[1]);
+
+ (void)printf("%s\n", b);
+ return 0;
+}
+#endif
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_readlink.c b/contrib/netbsd-tests/lib/libc/ssp/h_readlink.c
new file mode 100644
index 0000000..7e8bff6
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_readlink.c
@@ -0,0 +1,66 @@
+/* $NetBSD: h_readlink.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+
+/*
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: h_readlink.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+
+#include <sys/param.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#ifdef __FreeBSD__
+#include <err.h>
+#include <string.h>
+#endif
+
+int
+main(int argc, char *argv[])
+{
+#ifdef __FreeBSD__
+ char b[512], *sl;
+ int n;
+ size_t len = atoi(argv[1]);
+ sl = malloc(len);
+ memset(sl, 'a', len);
+ sl[len - 1] = 0;
+ unlink("symlink");
+ if (symlink(sl, "symlink") == -1)
+ err(1, "symlink()");
+ n = readlink("symlink", b, len);
+ unlink("symlink");
+#else
+ char b[MAXPATHLEN];
+ size_t len = atoi(argv[1]);
+ (void)readlink("/", b, len);
+#endif
+ (void)printf("%s\n", b);
+ return 0;
+}
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_snprintf.c b/contrib/netbsd-tests/lib/libc/ssp/h_snprintf.c
new file mode 100644
index 0000000..7576788
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_snprintf.c
@@ -0,0 +1,51 @@
+/* $NetBSD: h_snprintf.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+
+/*
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: h_snprintf.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ char b[10];
+ size_t len = atoi(argv[1]);
+#ifdef __FreeBSD__
+ char c[] = "01234567890123456789";
+ c[len] = 0;
+ (void)snprintf(b, len, "%s", c);
+#else
+ (void)snprintf(b, len, "%s", "0123456789");
+#endif
+ (void)printf("%s\n", b);
+ return 0;
+}
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_sprintf.c b/contrib/netbsd-tests/lib/libc/ssp/h_sprintf.c
new file mode 100644
index 0000000..0f6d0cb
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_sprintf.c
@@ -0,0 +1,43 @@
+/* $NetBSD: h_sprintf.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+
+/*
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: h_sprintf.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+
+#include <stdio.h>
+
+int
+main(int argc, char *argv[])
+{
+ char b[10];
+ (void)sprintf(b, "%s", argv[1]);
+ (void)printf("%s\n", b);
+ return 0;
+}
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_stpcpy.c b/contrib/netbsd-tests/lib/libc/ssp/h_stpcpy.c
new file mode 100644
index 0000000..c8dfbb7
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_stpcpy.c
@@ -0,0 +1,49 @@
+/* $NetBSD: h_stpcpy.c,v 1.1 2014/04/06 19:28:59 christos Exp $ */
+
+/*
+ * Copyright (c) 2014 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: h_stpcpy.c,v 1.1 2014/04/06 19:28:59 christos Exp $");
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main(int argc, char *argv[])
+{
+ char b[10];
+ char *q = stpcpy(b, argv[1]);
+
+ if ((size_t)(q - b) != strlen(argv[1]))
+ abort();
+
+ (void)printf("%s\n", b);
+ return 0;
+}
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_stpncpy.c b/contrib/netbsd-tests/lib/libc/ssp/h_stpncpy.c
new file mode 100644
index 0000000..c03d2a8
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_stpncpy.c
@@ -0,0 +1,56 @@
+/* $NetBSD: h_stpncpy.c,v 1.2 2014/04/07 15:09:20 christos Exp $ */
+
+/*
+ * Copyright (c) 2014 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: h_stpncpy.c,v 1.2 2014/04/07 15:09:20 christos Exp $");
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ char b[10];
+ int len = atoi(argv[1]);
+#if __GNUC_PREREQ__(4, 8)
+ char *q = stpncpy(b, "1020202020202", len);
+
+ if (q - b != len)
+ abort();
+#else
+ // gcc-4.5 lacks __builtin___stpncpy_chk, lose.
+ (void)strncpy(b, "1020202020202", len);
+#endif
+
+ (void)printf("%*.*s\n", len, len, b);
+ return 0;
+}
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_strcat.c b/contrib/netbsd-tests/lib/libc/ssp/h_strcat.c
new file mode 100644
index 0000000..687acf7
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_strcat.c
@@ -0,0 +1,46 @@
+/* $NetBSD: h_strcat.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+
+/*
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: h_strcat.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+
+#include <stdio.h>
+#include <string.h>
+
+int
+main(int argc, char *argv[])
+{
+ char b[10];
+ (void)strcpy(b, "1");
+ (void)strcat(b, argv[1]);
+
+ (void)printf("%s\n", b);
+ return 0;
+}
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_strcpy.c b/contrib/netbsd-tests/lib/libc/ssp/h_strcpy.c
new file mode 100644
index 0000000..2a7f1f5
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_strcpy.c
@@ -0,0 +1,45 @@
+/* $NetBSD: h_strcpy.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+
+/*
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: h_strcpy.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+
+#include <stdio.h>
+#include <string.h>
+
+int
+main(int argc, char *argv[])
+{
+ char b[10];
+ (void)strcpy(b, argv[1]);
+
+ (void)printf("%s\n", b);
+ return 0;
+}
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_strncat.c b/contrib/netbsd-tests/lib/libc/ssp/h_strncat.c
new file mode 100644
index 0000000..0d66c7b
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_strncat.c
@@ -0,0 +1,48 @@
+/* $NetBSD: h_strncat.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+
+/*
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: h_strncat.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ char b[10];
+ int len = atoi(argv[1]);
+ (void)strcpy(b, "1");
+ (void)strncat(b, "1020202020202", len);
+
+ (void)printf("%*.*s\n", len, len, b);
+ return 0;
+}
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_strncpy.c b/contrib/netbsd-tests/lib/libc/ssp/h_strncpy.c
new file mode 100644
index 0000000..fddf67b
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_strncpy.c
@@ -0,0 +1,47 @@
+/* $NetBSD: h_strncpy.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+
+/*
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: h_strncpy.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ char b[10];
+ int len = atoi(argv[1]);
+ (void)strncpy(b, "1020202020202", len);
+
+ (void)printf("%*.*s\n", len, len, b);
+ return 0;
+}
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_vsnprintf.c b/contrib/netbsd-tests/lib/libc/ssp/h_vsnprintf.c
new file mode 100644
index 0000000..0f6af85
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_vsnprintf.c
@@ -0,0 +1,57 @@
+/* $NetBSD: h_vsnprintf.c,v 1.3 2012/03/15 02:02:22 joerg Exp $ */
+
+/*
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: h_vsnprintf.c,v 1.3 2012/03/15 02:02:22 joerg Exp $");
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+static void wrap(size_t, const char *, ...) __printflike(2, 3);
+
+void
+wrap(size_t len, const char *fmt, ...)
+{
+ char b[10];
+ va_list ap;
+ va_start(ap, fmt);
+ (void)vsnprintf(b, len, fmt, ap);
+ (void)printf("%s\n", b);
+ va_end(ap);
+}
+
+int
+main(int argc, char *argv[])
+{
+ size_t len = atoi(argv[1]);
+ wrap(len, "%s", "012345678901234567890");
+ return 0;
+}
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_vsprintf.c b/contrib/netbsd-tests/lib/libc/ssp/h_vsprintf.c
new file mode 100644
index 0000000..c7fc780
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_vsprintf.c
@@ -0,0 +1,55 @@
+/* $NetBSD: h_vsprintf.c,v 1.3 2012/03/15 02:02:22 joerg Exp $ */
+
+/*
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: h_vsprintf.c,v 1.3 2012/03/15 02:02:22 joerg Exp $");
+
+#include <stdio.h>
+#include <stdarg.h>
+
+static void wrap(const char *, ...) __printflike(1, 2);
+
+static void
+wrap(const char *fmt, ...)
+{
+ char b[10];
+ va_list ap;
+ va_start(ap, fmt);
+ (void)vsprintf(b, fmt, ap);
+ (void)printf("%s\n", b);
+ va_end(ap);
+}
+
+int
+main(int argc, char *argv[])
+{
+ wrap("%s", argv[1]);
+ return 0;
+}
diff --git a/contrib/netbsd-tests/lib/libc/ssp/t_ssp.sh b/contrib/netbsd-tests/lib/libc/ssp/t_ssp.sh
new file mode 100755
index 0000000..04adc67
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/ssp/t_ssp.sh
@@ -0,0 +1,459 @@
+# $NetBSD: t_ssp.sh,v 1.7 2014/04/06 19:28:59 christos Exp $
+#
+# Copyright (c) 2008 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+h_pass()
+{
+ echo "Executing command [ $2$1 ]"
+ eval $2 atf_check -s exit:0 -o ignore -e ignore $1
+}
+
+h_fail()
+{
+ echo "Executing command [ $2$1 ]"
+ # Begin FreeBSD
+ if true; then
+ eval $2 atf_check -s signal -o ignore -e ignore $1
+ else
+ # End FreeBSD
+ eval $2 atf_check -s signal:6 -o ignore -e ignore $1
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+}
+
+atf_test_case sprintf
+sprintf_head()
+{
+ atf_set "descr" "Checks sprintf(3)"
+}
+sprintf_body()
+{
+ prog="$(atf_get_srcdir)/h_sprintf"
+
+ h_pass "$prog ok"
+ # Begin FreeBSD
+ if true; then
+ h_fail "$prog 0123456789ab"
+ else
+ # End FreeBSD
+ h_fail "$prog 0123456789"
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+}
+
+atf_test_case vsprintf
+vsprintf_head()
+{
+ atf_set "descr" "Checks vsprintf(3)"
+}
+vsprintf_body()
+{
+ prog="$(atf_get_srcdir)/h_vsprintf"
+
+ h_pass "$prog ok"
+ # Begin FreeBSD
+ if true; then
+ h_fail "$prog 0123456789ab"
+ else
+ # End FreeBSD
+ h_fail "$prog 0123456789"
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+}
+
+atf_test_case snprintf
+snprintf_head()
+{
+ atf_set "descr" "Checks snprintf(3)"
+}
+snprintf_body()
+{
+ prog="$(atf_get_srcdir)/h_snprintf"
+
+ h_pass "$prog 10"
+ # Begin FreeBSD
+ if true; then
+ h_fail "$prog 13"
+ else
+ # End FreeBSD
+ h_fail "$prog 11"
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+}
+
+atf_test_case vsnprintf
+vsnprintf_head()
+{
+ atf_set "descr" "Checks vsnprintf(3)"
+}
+vsnprintf_body()
+{
+ prog="$(atf_get_srcdir)/h_vsnprintf"
+
+ h_pass "$prog 10"
+ # Begin FreeBSD
+ if true; then
+ h_fail "$prog 13"
+ else
+ # End FreeBSD
+ h_fail "$prog 11"
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+}
+
+atf_test_case gets
+gets_head()
+{
+ atf_set "descr" "Checks gets(3)"
+}
+gets_body()
+{
+ prog="$(atf_get_srcdir)/h_gets"
+
+ h_pass "$prog" "echo ok |"
+ # Begin FreeBSD
+ if true; then
+ h_fail "$prog" "echo 0123456789ab |"
+ else
+ # End FreeBSD
+ h_fail "$prog" "echo 0123456789 |"
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+}
+
+atf_test_case fgets
+fgets_head()
+{
+ atf_set "descr" "Checks fgets(3)"
+}
+fgets_body()
+{
+ prog="$(atf_get_srcdir)/h_fgets"
+
+ h_pass "$prog 10" "echo ok |"
+ # Begin FreeBSD
+ if true; then
+ h_fail "$prog 13" "echo 0123456789abc |"
+ else
+ # End FreeBSD
+ h_fail "$prog 11" "echo busted |"
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+}
+
+atf_test_case memcpy
+memcpy_head()
+{
+ atf_set "descr" "Checks memcpy(3)"
+}
+memcpy_body()
+{
+ prog="$(atf_get_srcdir)/h_memcpy"
+
+ h_pass "$prog 10"
+ # Begin FreeBSD
+ if true; then
+ h_fail "$prog 13"
+ else
+ # End FreeBSD
+ h_fail "$prog 11"
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+}
+
+atf_test_case memmove
+memmove_head()
+{
+ atf_set "descr" "Checks memmove(3)"
+}
+memmove_body()
+{
+ prog="$(atf_get_srcdir)/h_memmove"
+
+ h_pass "$prog 10"
+ # Begin FreeBSD
+ if true; then
+ h_fail "$prog 13"
+ else
+ # End FreeBSD
+ h_fail "$prog 11"
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+}
+
+atf_test_case memset
+memset_head()
+{
+ atf_set "descr" "Checks memset(3)"
+}
+memset_body()
+{
+ prog="$(atf_get_srcdir)/h_memset"
+
+ h_pass "$prog 10"
+ # Begin FreeBSD
+ if true; then
+ h_fail "$prog 13"
+ else
+ # End FreeBSD
+ h_fail "$prog 11"
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+}
+
+atf_test_case strcpy
+strcpy_head()
+{
+ atf_set "descr" "Checks strcpy(3)"
+}
+strcpy_body()
+{
+ prog="$(atf_get_srcdir)/h_strcpy"
+
+ h_pass "$prog 0123456"
+ # Begin FreeBSD
+ if true; then
+ h_fail "$prog 0123456789ab"
+ else
+ # End FreeBSD
+ h_fail "$prog 0123456789"
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+}
+
+atf_test_case stpcpy
+stpcpy_head()
+{
+ atf_set "descr" "Checks stpcpy(3)"
+}
+stpcpy_body()
+{
+ prog="$(atf_get_srcdir)/h_stpcpy"
+
+ h_pass "$prog 0123456"
+ # Begin FreeBSD
+ if true; then
+ h_fail "$prog 0123456789ab"
+ else
+ # End FreeBSD
+ h_fail "$prog 0123456789"
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+}
+
+atf_test_case strcat
+strcat_head()
+{
+ atf_set "descr" "Checks strcat(3)"
+}
+strcat_body()
+{
+ prog="$(atf_get_srcdir)/h_strcat"
+
+ h_pass "$prog 0123456"
+ h_fail "$prog 0123456789ABCDEF"
+}
+
+atf_test_case strncpy
+strncpy_head()
+{
+ atf_set "descr" "Checks strncpy(3)"
+}
+strncpy_body()
+{
+ prog="$(atf_get_srcdir)/h_strncpy"
+
+ h_pass "$prog 10"
+ # Begin FreeBSD
+ if true; then
+ h_fail "$prog 13"
+ else
+ # End FreeBSD
+ h_fail "$prog 11"
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+}
+
+atf_test_case stpncpy
+stpncpy_head()
+{
+ atf_set "descr" "Checks stpncpy(3)"
+}
+stpncpy_body()
+{
+ prog="$(atf_get_srcdir)/h_stpncpy"
+
+ h_pass "$prog 10"
+ # Begin FreeBSD
+ if true; then
+ h_fail "$prog 13"
+ else
+ # End FreeBSD
+ h_fail "$prog 11"
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+}
+
+atf_test_case strncat
+strncat_head()
+{
+ atf_set "descr" "Checks strncat(3)"
+}
+strncat_body()
+{
+ prog="$(atf_get_srcdir)/h_strncat"
+
+ # Begin FreeBSD
+ h_pass "$prog 8"
+ if true; then
+ h_fail "$prog 11"
+ else
+ # End FreeBSD
+ h_fail "$prog 9"
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+}
+
+atf_test_case raw
+raw_head()
+{
+ atf_set "descr" "Checks raw array overflow"
+}
+raw_body()
+{
+ prog="$(atf_get_srcdir)/h_raw"
+
+ h_pass "$prog 9"
+ # Begin FreeBSD
+ if true; then
+ h_fail "$prog 12"
+ else
+ # End FreeBSD
+ h_fail "$prog 10"
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+}
+
+atf_test_case read
+read_head()
+{
+ atf_set "descr" "Checks read(2)"
+}
+read_body()
+{
+ prog="$(atf_get_srcdir)/h_read"
+
+ h_pass "$prog 1024" "echo foo |"
+ # Begin FreeBSD
+ if true; then
+ h_fail "$prog 1027" "echo bar |"
+ else
+ # End FreeBSD
+ h_fail "$prog 1025" "echo bar |"
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+}
+
+atf_test_case readlink
+readlink_head()
+{
+ atf_set "descr" "Checks readlink(2)"
+}
+readlink_body()
+{
+ prog="$(atf_get_srcdir)/h_readlink"
+
+ # Begin FreeBSD
+ if true; then
+ h_pass "$prog 512"
+ h_fail "$prog 523"
+ else
+ # End FreeBSD
+ h_pass "$prog 1024"
+ h_fail "$prog 1025"
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+}
+
+atf_test_case getcwd
+getcwd_head()
+{
+ atf_set "descr" "Checks getcwd(3)"
+}
+getcwd_body()
+{
+ prog="$(atf_get_srcdir)/h_getcwd"
+
+ h_pass "$prog 1024"
+ # Begin FreeBSD
+ if false; then
+ # End FreeBSD
+ h_fail "$prog 1025"
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case sprintf
+ atf_add_test_case vsprintf
+ atf_add_test_case snprintf
+ atf_add_test_case vsnprintf
+ atf_add_test_case gets
+ atf_add_test_case fgets
+ atf_add_test_case memcpy
+ atf_add_test_case memmove
+ atf_add_test_case memset
+ atf_add_test_case stpcpy
+ atf_add_test_case stpncpy
+ atf_add_test_case strcat
+ atf_add_test_case strcpy
+ atf_add_test_case strncat
+ atf_add_test_case strncpy
+ atf_add_test_case raw
+ atf_add_test_case read
+ atf_add_test_case readlink
+ atf_add_test_case getcwd
+}
OpenPOWER on IntegriCloud