CVS commit: src/tests/lib/libc/ssp
Module Name:src Committed By: christos Date: Mon Jan 16 16:35:57 UTC 2017 Modified Files: src/tests/lib/libc/ssp: h_read.c Log Message: PR/51894: Ngie Cooper: Use /dev/zero to read instead of stdin To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/ssp/h_read.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/ssp/h_read.c diff -u src/tests/lib/libc/ssp/h_read.c:1.1 src/tests/lib/libc/ssp/h_read.c:1.2 --- src/tests/lib/libc/ssp/h_read.c:1.1 Sun Dec 26 21:04:19 2010 +++ src/tests/lib/libc/ssp/h_read.c Mon Jan 16 11:35:57 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: h_read.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */ +/* $NetBSD: h_read.c,v 1.2 2017/01/16 16:35:57 christos Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,9 +29,11 @@ #include __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 $"); +__RCSID("$NetBSD: h_read.c,v 1.2 2017/01/16 16:35:57 christos Exp $"); #include +#include +#include #include #include #include @@ -40,8 +42,13 @@ int main(int argc, char *argv[]) { char b[MAXPATHLEN]; + int fd, n; size_t len = atoi(argv[1]); - (void)read(0, b, len); + + if ((fd = open(_PATH_DEVZERO, O_RDONLY)) == -1) + abort(); + if ((n = read(fd, b, len)) == -1) + abort(); (void)printf("%s\n", b); - return 0; + return (0); }
CVS commit: src/tests/lib/libc/ssp
Module Name:src Committed By: christos Date: Mon Jan 16 16:34:24 UTC 2017 Modified Files: src/tests/lib/libc/ssp: h_memset.c Log Message: PR/51893: Ngie Cooper: prevent toolchain from optimizing out memset call To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/ssp/h_memset.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/ssp/h_memset.c diff -u src/tests/lib/libc/ssp/h_memset.c:1.1 src/tests/lib/libc/ssp/h_memset.c:1.2 --- src/tests/lib/libc/ssp/h_memset.c:1.1 Sun Dec 26 21:04:19 2010 +++ src/tests/lib/libc/ssp/h_memset.c Mon Jan 16 11:34:24 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: h_memset.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */ +/* $NetBSD: h_memset.c,v 1.2 2017/01/16 16:34:24 christos Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ #include __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 $"); +__RCSID("$NetBSD: h_memset.c,v 1.2 2017/01/16 16:34:24 christos Exp $"); #include #include @@ -41,5 +41,5 @@ main(int argc, char *argv[]) char b[10]; size_t len = atoi(argv[1]); (void)memset(b, 0, len); - return 0; + return b[0]; /* keeps optimizer from zapping the call to memset() */ }
CVS commit: src/tests/lib/libc/ssp
Module Name:src Committed By: christos Date: Mon Apr 7 15:09:20 UTC 2014 Modified Files: src/tests/lib/libc/ssp: h_stpncpy.c Log Message: fix lossage with gcc-4.5 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/ssp/h_stpncpy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/ssp/h_stpncpy.c diff -u src/tests/lib/libc/ssp/h_stpncpy.c:1.1 src/tests/lib/libc/ssp/h_stpncpy.c:1.2 --- src/tests/lib/libc/ssp/h_stpncpy.c:1.1 Sun Apr 6 15:28:59 2014 +++ src/tests/lib/libc/ssp/h_stpncpy.c Mon Apr 7 11:09:20 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: h_stpncpy.c,v 1.1 2014/04/06 19:28:59 christos Exp $ */ +/* $NetBSD: h_stpncpy.c,v 1.2 2014/04/07 15:09:20 christos Exp $ */ /* * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ #include sys/cdefs.h __COPYRIGHT(@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved.); -__RCSID($NetBSD: h_stpncpy.c,v 1.1 2014/04/06 19:28:59 christos Exp $); +__RCSID($NetBSD: h_stpncpy.c,v 1.2 2014/04/07 15:09:20 christos Exp $); #include stdio.h #include string.h @@ -41,10 +41,15 @@ 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;
CVS commit: src/tests/lib/libc/ssp
Module Name:src Committed By: christos Date: Sun Apr 6 19:28:59 UTC 2014 Modified Files: src/tests/lib/libc/ssp: Makefile t_ssp.sh Added Files: src/tests/lib/libc/ssp: h_stpcpy.c h_stpncpy.c Log Message: add stp*cpy() tests To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/ssp/Makefile \ src/tests/lib/libc/ssp/t_ssp.sh cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/ssp/h_stpcpy.c \ src/tests/lib/libc/ssp/h_stpncpy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/ssp/Makefile diff -u src/tests/lib/libc/ssp/Makefile:1.6 src/tests/lib/libc/ssp/Makefile:1.7 --- src/tests/lib/libc/ssp/Makefile:1.6 Sun Sep 23 13:22:25 2012 +++ src/tests/lib/libc/ssp/Makefile Sun Apr 6 15:28:59 2014 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.6 2012/09/23 17:22:25 joerg Exp $ +# $NetBSD: Makefile,v 1.7 2014/04/06 19:28:59 christos Exp $ NOMAN= # defined @@ -39,6 +39,8 @@ PROGS+= h_read PROGS+= h_readlink PROGS+= h_snprintf PROGS+= h_sprintf +PROGS+= h_stpcpy +PROGS+= h_stpncpy PROGS+= h_strcat PROGS+= h_strcpy PROGS+= h_strncat Index: src/tests/lib/libc/ssp/t_ssp.sh diff -u src/tests/lib/libc/ssp/t_ssp.sh:1.6 src/tests/lib/libc/ssp/t_ssp.sh:1.7 --- src/tests/lib/libc/ssp/t_ssp.sh:1.6 Fri Jan 10 05:45:34 2014 +++ src/tests/lib/libc/ssp/t_ssp.sh Sun Apr 6 15:28:59 2014 @@ -1,4 +1,4 @@ -# $NetBSD: t_ssp.sh,v 1.6 2014/01/10 10:45:34 martin Exp $ +# $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. @@ -167,6 +167,19 @@ strcpy_body() h_fail $prog 0123456789 } +atf_test_case stpcpy +stpcpy_head() +{ + atf_set descr Checks stpcpy(3) +} +stpcpy_body() +{ + prog=$(atf_get_srcdir)/h_stpcpy + + h_pass $prog 0123456 + h_fail $prog 0123456789 +} + atf_test_case strcat strcat_head() { @@ -193,6 +206,19 @@ strncpy_body() h_fail $prog 11 } +atf_test_case stpncpy +stpncpy_head() +{ + atf_set descr Checks stpncpy(3) +} +stpncpy_body() +{ + prog=$(atf_get_srcdir)/h_stpncpy + + h_pass $prog 10 + h_fail $prog 11 +} + atf_test_case strncat strncat_head() { @@ -269,6 +295,8 @@ atf_init_test_cases() 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 Added files: Index: src/tests/lib/libc/ssp/h_stpcpy.c diff -u /dev/null src/tests/lib/libc/ssp/h_stpcpy.c:1.1 --- /dev/null Sun Apr 6 15:28:59 2014 +++ src/tests/lib/libc/ssp/h_stpcpy.c Sun Apr 6 15:28:59 2014 @@ -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; +} Index: src/tests/lib/libc/ssp/h_stpncpy.c diff -u /dev/null src/tests/lib/libc/ssp/h_stpncpy.c:1.1 --- /dev/null Sun Apr 6 15:28:59 2014 +++ src/tests/lib/libc/ssp/h_stpncpy.c Sun Apr 6 15:28:59 2014 @@ -0,0 +1,51 @@ +/* $NetBSD: h_stpncpy.c,v 1.1 2014/04/06 19:28:59 christos Exp $ */ + +/* + * Copyright (c) 2014 The NetBSD Foundation, Inc. + *
CVS commit: src/tests/lib/libc/ssp
Module Name:src Committed By: martin Date: Fri Jan 10 10:45:34 UTC 2014 Modified Files: src/tests/lib/libc/ssp: t_ssp.sh Log Message: In the strcat test, smash the stack more severely (this all may depend on alignment and stack frame details). The gcc folks disagree with this test in general: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59750 To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 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/tests/lib/libc/ssp/t_ssp.sh diff -u src/tests/lib/libc/ssp/t_ssp.sh:1.5 src/tests/lib/libc/ssp/t_ssp.sh:1.6 --- src/tests/lib/libc/ssp/t_ssp.sh:1.5 Sun Jun 12 21:12:46 2011 +++ src/tests/lib/libc/ssp/t_ssp.sh Fri Jan 10 10:45:34 2014 @@ -1,4 +1,4 @@ -# $NetBSD: t_ssp.sh,v 1.5 2011/06/12 21:12:46 plunky Exp $ +# $NetBSD: t_ssp.sh,v 1.6 2014/01/10 10:45:34 martin Exp $ # # Copyright (c) 2008 The NetBSD Foundation, Inc. # All rights reserved. @@ -177,7 +177,7 @@ strcat_body() prog=$(atf_get_srcdir)/h_strcat h_pass $prog 0123456 - h_fail $prog 012345678 + h_fail $prog 0123456789ABCDEF } atf_test_case strncpy
CVS commit: src/tests/lib/libc/ssp
Module Name:src Committed By: christos Date: Sun Jul 24 14:00:36 UTC 2011 Modified Files: src/tests/lib/libc/ssp: h_raw.c Log Message: make sum volatile to avoid printing To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/ssp/h_raw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/ssp/h_raw.c diff -u src/tests/lib/libc/ssp/h_raw.c:1.5 src/tests/lib/libc/ssp/h_raw.c:1.6 --- src/tests/lib/libc/ssp/h_raw.c:1.5 Sat Jul 23 18:17:43 2011 +++ src/tests/lib/libc/ssp/h_raw.c Sun Jul 24 10:00:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: h_raw.c,v 1.5 2011/07/23 22:17:43 martin Exp $ */ +/* $NetBSD: h_raw.c,v 1.6 2011/07/24 14:00:36 christos Exp $ */ /* * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ #include sys/cdefs.h __COPYRIGHT(@(#) Copyright (c) 2011\ The NetBSD Foundation, inc. All rights reserved.); -__RCSID($NetBSD: h_raw.c,v 1.5 2011/07/23 22:17:43 martin Exp $); +__RCSID($NetBSD: h_raw.c,v 1.6 2011/07/24 14:00:36 christos Exp $); #include stdio.h #include stdlib.h @@ -40,12 +40,11 @@ poke(int *b, size_t index) { size_t i; - int sum = 0; + volatile int sum = 0; b[index] = 42; for (i = 0; i 10; i++) sum += b[i]; - printf(dummy value: %d\n, sum); } int
CVS commit: src/tests/lib/libc/ssp
Module Name:src Committed By: martin Date: Sat Jul 23 22:17:43 UTC 2011 Modified Files: src/tests/lib/libc/ssp: h_raw.c Log Message: gcc optimizes away the side effect free call to the poke function which is supposed to smash our stack in this test case. So: make it print out some dummy value based on the smashing changes. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/ssp/h_raw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/ssp/h_raw.c diff -u src/tests/lib/libc/ssp/h_raw.c:1.4 src/tests/lib/libc/ssp/h_raw.c:1.5 --- src/tests/lib/libc/ssp/h_raw.c:1.4 Wed Jun 15 06:09:21 2011 +++ src/tests/lib/libc/ssp/h_raw.c Sat Jul 23 22:17:43 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: h_raw.c,v 1.4 2011/06/15 06:09:21 plunky Exp $ */ +/* $NetBSD: h_raw.c,v 1.5 2011/07/23 22:17:43 martin Exp $ */ /* * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,8 +29,9 @@ #include sys/cdefs.h __COPYRIGHT(@(#) Copyright (c) 2011\ The NetBSD Foundation, inc. All rights reserved.); -__RCSID($NetBSD: h_raw.c,v 1.4 2011/06/15 06:09:21 plunky Exp $); +__RCSID($NetBSD: h_raw.c,v 1.5 2011/07/23 22:17:43 martin Exp $); +#include stdio.h #include stdlib.h void poke(int *, size_t); @@ -38,7 +39,13 @@ void poke(int *b, size_t index) { + size_t i; + int sum = 0; + b[index] = 42; + for (i = 0; i 10; i++) + sum += b[i]; + printf(dummy value: %d\n, sum); } int
CVS commit: src/tests/lib/libc/ssp
Module Name:src Committed By: plunky Date: Wed Jun 15 06:09:22 UTC 2011 Modified Files: src/tests/lib/libc/ssp: h_raw.c Log Message: gcc seems to pad small character arrays, use an array of ints while here, make the poke function non-static, so that it doesnt get optimised away To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/ssp/h_raw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/ssp/h_raw.c diff -u src/tests/lib/libc/ssp/h_raw.c:1.3 src/tests/lib/libc/ssp/h_raw.c:1.4 --- src/tests/lib/libc/ssp/h_raw.c:1.3 Sun Jun 12 21:12:46 2011 +++ src/tests/lib/libc/ssp/h_raw.c Wed Jun 15 06:09:21 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: h_raw.c,v 1.3 2011/06/12 21:12:46 plunky Exp $ */ +/* $NetBSD: h_raw.c,v 1.4 2011/06/15 06:09:21 plunky Exp $ */ /* * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,20 +29,22 @@ #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 $); +__RCSID($NetBSD: h_raw.c,v 1.4 2011/06/15 06:09:21 plunky Exp $); #include stdlib.h -static void -poke(char *b, size_t index) +void poke(int *, size_t); + +void +poke(int *b, size_t index) { - b[index] = 'A'; + b[index] = 42; } int main(int argc, char *argv[]) { - char b[10]; + int b[10]; poke(b, atoi(argv[1])); return 0;
CVS commit: src/tests/lib/libc/ssp
Module Name:src Committed By: plunky Date: Sun Jun 12 19:22:02 UTC 2011 Modified Files: src/tests/lib/libc/ssp: Makefile Log Message: don't pass -fstack-protector for these, the tests are actually for the __*_chk functions included by -D_FORTIFY_SOURCE=2, and if the compiler provides additional protection, it can mask broken functions.. (none of the _chk functions will return or process any data if the length given is known to be larger than the buffer) To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/ssp/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/ssp/Makefile diff -u src/tests/lib/libc/ssp/Makefile:1.2 src/tests/lib/libc/ssp/Makefile:1.3 --- src/tests/lib/libc/ssp/Makefile:1.2 Sat Feb 26 02:41:33 2011 +++ src/tests/lib/libc/ssp/Makefile Sun Jun 12 19:22:01 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.2 2011/02/26 02:41:33 pgoyette Exp $ +# $NetBSD: Makefile,v 1.3 2011/06/12 19:22:01 plunky Exp $ NOMAN= # defined @@ -7,8 +7,6 @@ WARNS= 4 CPPFLAGS+= -D_FORTIFY_SOURCE=2 -CFLAGS+= -fstack-protector-all -Wstack-protector -LDFLAGS+= -fstack-protector-all -Wstack-protector # Bootstrap hack
CVS commit: src/tests/lib/libc/ssp
Module Name:src Committed By: pgoyette Date: Fri Feb 25 18:11:53 UTC 2011 Modified Files: src/tests/lib/libc/ssp: t_ssp.sh Log Message: Disable the raw test case. The test is bogus, and did not work before conversion from src/regress/ to atf To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 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/tests/lib/libc/ssp/t_ssp.sh diff -u src/tests/lib/libc/ssp/t_ssp.sh:1.2 src/tests/lib/libc/ssp/t_ssp.sh:1.3 --- src/tests/lib/libc/ssp/t_ssp.sh:1.2 Mon Dec 27 05:27:34 2010 +++ src/tests/lib/libc/ssp/t_ssp.sh Fri Feb 25 18:11:53 2011 @@ -1,4 +1,4 @@ -# $NetBSD: t_ssp.sh,v 1.2 2010/12/27 05:27:34 pgoyette Exp $ +# $NetBSD: t_ssp.sh,v 1.3 2011/02/25 18:11:53 pgoyette Exp $ # # Copyright (c) 2008 The NetBSD Foundation, Inc. # All rights reserved. @@ -46,8 +46,9 @@ { prog=$(atf_get_srcdir)/h_raw - h_pass $prog 9 - h_fail $prog 10 + atk_skip Bogus test case +# h_pass $prog 9 +# h_fail $prog 10 } atf_test_case sprintf
CVS commit: src/tests/lib/libc/ssp
Module Name:src Committed By: pgoyette Date: Sat Feb 26 02:41:34 UTC 2011 Modified Files: src/tests/lib/libc/ssp: Makefile t_ssp.sh Removed Files: src/tests/lib/libc/ssp: h_raw.c Log Message: The ssp/raw test is useless. Remove it. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/ssp/Makefile cvs rdiff -u -r1.1 -r0 src/tests/lib/libc/ssp/h_raw.c cvs rdiff -u -r1.3 -r1.4 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/tests/lib/libc/ssp/Makefile diff -u src/tests/lib/libc/ssp/Makefile:1.1 src/tests/lib/libc/ssp/Makefile:1.2 --- src/tests/lib/libc/ssp/Makefile:1.1 Mon Dec 27 02:04:19 2010 +++ src/tests/lib/libc/ssp/Makefile Sat Feb 26 02:41:33 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ +# $NetBSD: Makefile,v 1.2 2011/02/26 02:41:33 pgoyette Exp $ NOMAN= # defined @@ -32,7 +32,6 @@ 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.3 src/tests/lib/libc/ssp/t_ssp.sh:1.4 --- src/tests/lib/libc/ssp/t_ssp.sh:1.3 Fri Feb 25 18:11:53 2011 +++ src/tests/lib/libc/ssp/t_ssp.sh Sat Feb 26 02:41:33 2011 @@ -1,4 +1,4 @@ -# $NetBSD: t_ssp.sh,v 1.3 2011/02/25 18:11:53 pgoyette Exp $ +# $NetBSD: t_ssp.sh,v 1.4 2011/02/26 02:41:33 pgoyette Exp $ # # Copyright (c) 2008 The NetBSD Foundation, Inc. # All rights reserved. @@ -37,20 +37,6 @@ eval $2 atf_check -s signal:6 -o ignore -e ignore $1 } -atf_test_case raw -raw_head() -{ - atf_set descr Checks basic stack protection -} -raw_body() -{ - prog=$(atf_get_srcdir)/h_raw - - atk_skip Bogus test case -# h_pass $prog 9 -# h_fail $prog 10 -} - atf_test_case sprintf sprintf_head() { @@ -261,7 +247,6 @@ atf_init_test_cases() { - atf_add_test_case raw atf_add_test_case sprintf atf_add_test_case vsprintf atf_add_test_case snprintf
CVS commit: src/tests/lib/libc/ssp
Module Name:src Committed By: christos Date: Tue Dec 28 16:18:46 UTC 2010 Modified Files: src/tests/lib/libc/ssp: h_vsnprintf.c h_vsprintf.c Log Message: allocate the buffer at the same function level as the compiler so that the compiler knows to emit the right _chk call. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/ssp/h_vsnprintf.c \ src/tests/lib/libc/ssp/h_vsprintf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/ssp/h_vsnprintf.c diff -u src/tests/lib/libc/ssp/h_vsnprintf.c:1.1 src/tests/lib/libc/ssp/h_vsnprintf.c:1.2 --- src/tests/lib/libc/ssp/h_vsnprintf.c:1.1 Sun Dec 26 21:04:19 2010 +++ src/tests/lib/libc/ssp/h_vsnprintf.c Tue Dec 28 11:18:46 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: h_vsnprintf.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */ +/* $NetBSD: h_vsnprintf.c,v 1.2 2010/12/28 16:18:46 christos Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,29 +29,29 @@ #include sys/cdefs.h __COPYRIGHT(@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved.); -__RCSID($NetBSD: h_vsnprintf.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $); +__RCSID($NetBSD: h_vsnprintf.c,v 1.2 2010/12/28 16:18:46 christos Exp $); #include stdio.h #include stdlib.h #include stdarg.h -static void wrap(char *str, size_t, const char *, ...); +void wrap(size_t, const char *, ...); -static void -wrap(char *str, size_t len, const char *fmt, ...) +void +wrap(size_t len, const char *fmt, ...) { + char b[10]; va_list ap; va_start(ap, fmt); - (void)vsnprintf(str, len, fmt, ap); + (void)vsnprintf(b, len, fmt, ap); + (void)printf(%s\n, b); va_end(ap); } int main(int argc, char *argv[]) { - char b[10]; size_t len = atoi(argv[1]); - wrap(b, len, %s, 012345678910); - (void)printf(%s\n, b); + wrap(len, %s, 012345678901234567890); return 0; } Index: src/tests/lib/libc/ssp/h_vsprintf.c diff -u src/tests/lib/libc/ssp/h_vsprintf.c:1.1 src/tests/lib/libc/ssp/h_vsprintf.c:1.2 --- src/tests/lib/libc/ssp/h_vsprintf.c:1.1 Sun Dec 26 21:04:19 2010 +++ src/tests/lib/libc/ssp/h_vsprintf.c Tue Dec 28 11:18:46 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: h_vsprintf.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */ +/* $NetBSD: h_vsprintf.c,v 1.2 2010/12/28 16:18:46 christos Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,27 +29,27 @@ #include sys/cdefs.h __COPYRIGHT(@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved.); -__RCSID($NetBSD: h_vsprintf.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $); +__RCSID($NetBSD: h_vsprintf.c,v 1.2 2010/12/28 16:18:46 christos Exp $); #include stdio.h #include stdarg.h -static void wrap(char *str, const char *, ...); +static void wrap(const char *, ...); static void -wrap(char *str, const char *fmt, ...) +wrap(const char *fmt, ...) { + char b[10]; va_list ap; va_start(ap, fmt); - (void)vsprintf(str, fmt, ap); + (void)vsprintf(b, fmt, ap); + (void)printf(%s\n, b); va_end(ap); } int main(int argc, char *argv[]) { - char b[10]; - wrap(b, %s, argv[1]); - (void)printf(%s\n, b); + wrap(%s, argv[1]); return 0; }
CVS commit: src/tests/lib/libc/ssp
Module Name:src Committed By: pgoyette Date: Mon Dec 27 05:27:34 UTC 2010 Modified Files: src/tests/lib/libc/ssp: t_ssp.sh Log Message: Since atf_check doesn't deal with a pipeline, modify the tests to pipe the output of the echo commands to atf_check itself. This fixes the three new ssp failures. Note that the raw, strcpy, vsprintf, and vsnprintf tests still fail, but they failed in the old 'regress' style, too. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 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/tests/lib/libc/ssp/t_ssp.sh diff -u src/tests/lib/libc/ssp/t_ssp.sh:1.1 src/tests/lib/libc/ssp/t_ssp.sh:1.2 --- src/tests/lib/libc/ssp/t_ssp.sh:1.1 Mon Dec 27 02:04:19 2010 +++ src/tests/lib/libc/ssp/t_ssp.sh Mon Dec 27 05:27:34 2010 @@ -1,4 +1,4 @@ -# $NetBSD: t_ssp.sh,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ +# $NetBSD: t_ssp.sh,v 1.2 2010/12/27 05:27:34 pgoyette Exp $ # # Copyright (c) 2008 The NetBSD Foundation, Inc. # All rights reserved. @@ -27,14 +27,14 @@ h_pass() { - echo Executing command [ $1 ] - atf_check -s exit:0 -o ignore -e ignore $1 + echo Executing command [ $2$1 ] + eval $2 atf_check -s exit:0 -o ignore -e ignore $1 } h_fail() { - echo Executing command [ $1 ] - atf_check -s signal:6 -o ignore -e ignore $1 + echo Executing command [ $2$1 ] + eval $2 atf_check -s signal:6 -o ignore -e ignore $1 } atf_test_case raw @@ -111,8 +111,8 @@ { prog=$(atf_get_srcdir)/h_gets - h_pass echo ok | $prog - h_fail echo 0123456789 | $prog + h_pass $prog echo ok | + h_fail $prog echo 0123456789 | } atf_test_case fgets @@ -124,8 +124,8 @@ { prog=$(atf_get_srcdir)/h_fgets - h_pass echo ok | $prog 10 - h_fail echo busted | $prog 11 + h_pass $prog 10 echo ok | + h_fail $prog 11 echo busted | } atf_test_case memcpy @@ -228,8 +228,8 @@ { prog=$(atf_get_srcdir)/h_read - h_pass echo foo | $prog 1024 - h_fail echo bar | $prog 1025 + h_pass $prog 1024 echo foo | + h_fail $prog 1025 echo bar | } atf_test_case readlink