Module Name: src
Committed By: plunky
Date: Sun Jun 12 21:12:46 UTC 2011
Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/lib/libc/ssp: Makefile t_ssp.sh
Added Files:
src/tests/lib/libc/ssp: h_raw.c
Log Message:
reinstate ssp:raw test, slightly differently.. this one is built
with -fstack-protector-all and tests that the compiler built in
stack protection works, by poking directly outside the buffer
To generate a diff of this commit:
cvs rdiff -u -r1.349 -r1.350 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/ssp/Makefile
cvs rdiff -u -r0 -r1.3 src/tests/lib/libc/ssp/h_raw.c
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/ssp/t_ssp.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.349 src/distrib/sets/lists/tests/mi:1.350
--- src/distrib/sets/lists/tests/mi:1.349 Thu Jun 9 05:26:01 2011
+++ src/distrib/sets/lists/tests/mi Sun Jun 12 21:12:46 2011
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.349 2011/06/09 05:26:01 spz Exp $
+# $NetBSD: mi,v 1.350 2011/06/12 21:12:46 plunky Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -416,7 +416,7 @@
./usr/libdata/debug/usr/tests/lib/libc/ssp/h_memcpy.debug tests-lib-debug debug,atf,ssp
./usr/libdata/debug/usr/tests/lib/libc/ssp/h_memmove.debug tests-lib-debug debug,atf,ssp
./usr/libdata/debug/usr/tests/lib/libc/ssp/h_memset.debug tests-lib-debug debug,atf,ssp
-./usr/libdata/debug/usr/tests/lib/libc/ssp/h_raw.debug tests-obsolete obsolete
+./usr/libdata/debug/usr/tests/lib/libc/ssp/h_raw.debug tests-lib-debug debug,atf,ssp
./usr/libdata/debug/usr/tests/lib/libc/ssp/h_read.debug tests-lib-debug debug,atf,ssp
./usr/libdata/debug/usr/tests/lib/libc/ssp/h_readlink.debug tests-lib-debug debug,atf,ssp
./usr/libdata/debug/usr/tests/lib/libc/ssp/h_snprintf.debug tests-lib-debug debug,atf,ssp
@@ -1930,7 +1930,7 @@
./usr/tests/lib/libc/ssp/h_memcpy tests-lib-tests atf,ssp
./usr/tests/lib/libc/ssp/h_memmove tests-lib-tests atf,ssp
./usr/tests/lib/libc/ssp/h_memset tests-lib-tests atf,ssp
-./usr/tests/lib/libc/ssp/h_raw tests-obsolete obsolete
+./usr/tests/lib/libc/ssp/h_raw tests-lib-tests atf,ssp
./usr/tests/lib/libc/ssp/h_read tests-lib-tests atf,ssp
./usr/tests/lib/libc/ssp/h_readlink tests-lib-tests atf,ssp
./usr/tests/lib/libc/ssp/h_snprintf tests-lib-tests atf,ssp
Index: src/tests/lib/libc/ssp/Makefile
diff -u src/tests/lib/libc/ssp/Makefile:1.3 src/tests/lib/libc/ssp/Makefile:1.4
--- src/tests/lib/libc/ssp/Makefile:1.3 Sun Jun 12 19:22:01 2011
+++ src/tests/lib/libc/ssp/Makefile Sun Jun 12 21:12:46 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.3 2011/06/12 19:22:01 plunky Exp $
+# $NetBSD: Makefile,v 1.4 2011/06/12 21:12:46 plunky Exp $
NOMAN= # defined
@@ -8,6 +8,8 @@
CPPFLAGS+= -D_FORTIFY_SOURCE=2
+COPTS.h_raw.c= -fstack-protector-all -Wstack-protector --param=ssp-buffer-size=1
+
# Bootstrap hack
.ifmake !clean && !obj && !cleandir
@@ -30,6 +32,7 @@
PROGS+= h_memcpy
PROGS+= h_memmove
PROGS+= h_memset
+PROGS+= h_raw
PROGS+= h_read
PROGS+= h_readlink
PROGS+= h_snprintf
Index: src/tests/lib/libc/ssp/t_ssp.sh
diff -u src/tests/lib/libc/ssp/t_ssp.sh:1.4 src/tests/lib/libc/ssp/t_ssp.sh:1.5
--- src/tests/lib/libc/ssp/t_ssp.sh:1.4 Sat Feb 26 02:41:33 2011
+++ src/tests/lib/libc/ssp/t_ssp.sh Sun Jun 12 21:12:46 2011
@@ -1,4 +1,4 @@
-# $NetBSD: t_ssp.sh,v 1.4 2011/02/26 02:41:33 pgoyette Exp $
+# $NetBSD: t_ssp.sh,v 1.5 2011/06/12 21:12:46 plunky Exp $
#
# Copyright (c) 2008 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -206,6 +206,19 @@
h_fail "$prog 9"
}
+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"
+ h_fail "$prog 10"
+}
+
atf_test_case read
read_head()
{
@@ -260,6 +273,7 @@
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
Added files:
Index: src/tests/lib/libc/ssp/h_raw.c
diff -u /dev/null src/tests/lib/libc/ssp/h_raw.c:1.3
--- /dev/null Sun Jun 12 21:12:46 2011
+++ src/tests/lib/libc/ssp/h_raw.c Sun Jun 12 21:12:46 2011
@@ -0,0 +1,49 @@
+/* $NetBSD: h_raw.c,v 1.3 2011/06/12 21:12:46 plunky 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.3 2011/06/12 21:12:46 plunky Exp $");
+
+#include <stdlib.h>
+
+static void
+poke(char *b, size_t index)
+{
+ b[index] = 'A';
+}
+
+int
+main(int argc, char *argv[])
+{
+ char b[10];
+
+ poke(b, atoi(argv[1]));
+ return 0;
+}