CVS commit: src/lib/libc/ssp
Module Name:src Committed By: christos Date: Thu Dec 3 13:11:45 UTC 2015 Modified Files: src/lib/libc/ssp: ssp.3 Log Message: It is wrong to -I/usr/include/ssp To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/lib/libc/ssp/ssp.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/ssp.3 diff -u src/lib/libc/ssp/ssp.3:1.8 src/lib/libc/ssp/ssp.3:1.9 --- src/lib/libc/ssp/ssp.3:1.8 Wed Nov 6 21:01:42 2013 +++ src/lib/libc/ssp/ssp.3 Thu Dec 3 08:11:45 2015 @@ -1,4 +1,4 @@ -.\" $NetBSD: ssp.3,v 1.8 2013/11/07 02:01:42 christos Exp $ +.\" $NetBSD: ssp.3,v 1.9 2015/12/03 13:11:45 christos Exp $ .\" .\" Copyright (c) 2007 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -28,7 +28,7 @@ .\" POSSIBILITY OF SUCH DAMAGE. .\" .\" -.Dd November 6, 2013 +.Dd December 3, 2015 .Dt SSP 3 .Os .Sh NAME @@ -96,8 +96,6 @@ If an overflow is detected, the routines To enable these function overrides the following should be added to the .Xr gcc 1 command line: -.Dq \-I/usr/include/ssp -to override the standard include files and .Dq \-D_FORTIFY_SOURCE=1 or .Dq \-D_FORTIFY_SOURCE=2 .
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: joerg Date: Wed May 13 19:57:16 UTC 2015 Modified Files: src/lib/libc/ssp: memcpy_chk.c Log Message: void * is bad for computation, so cast to const char * first. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/lib/libc/ssp/memcpy_chk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/memcpy_chk.c diff -u src/lib/libc/ssp/memcpy_chk.c:1.6 src/lib/libc/ssp/memcpy_chk.c:1.7 --- src/lib/libc/ssp/memcpy_chk.c:1.6 Sat May 9 15:42:21 2015 +++ src/lib/libc/ssp/memcpy_chk.c Wed May 13 19:57:16 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: memcpy_chk.c,v 1.6 2015/05/09 15:42:21 christos Exp $ */ +/* $NetBSD: memcpy_chk.c,v 1.7 2015/05/13 19:57:16 joerg Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: memcpy_chk.c,v 1.6 2015/05/09 15:42:21 christos Exp $); +__RCSID($NetBSD: memcpy_chk.c,v 1.7 2015/05/13 19:57:16 joerg Exp $); /*LINTLIBRARY*/ @@ -47,7 +47,7 @@ __memcpy_chk(void * __restrict dst, cons if (len slen) __chk_fail(); - if (__ssp_overlap(src, dst, len)) + if (__ssp_overlap((const char *)src, (const char *)dst, len)) __chk_fail(); return memcpy(dst, src, len);
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: christos Date: Sat May 9 15:42:21 UTC 2015 Modified Files: src/lib/libc/ssp: memcpy_chk.c stpcpy_chk.c stpncpy_chk.c strcpy_chk.c strncpy_chk.c Log Message: add overlapping pointer checks To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/lib/libc/ssp/memcpy_chk.c \ src/lib/libc/ssp/stpcpy_chk.c src/lib/libc/ssp/strncpy_chk.c cvs rdiff -u -r1.2 -r1.3 src/lib/libc/ssp/stpncpy_chk.c cvs rdiff -u -r1.7 -r1.8 src/lib/libc/ssp/strcpy_chk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/memcpy_chk.c diff -u src/lib/libc/ssp/memcpy_chk.c:1.5 src/lib/libc/ssp/memcpy_chk.c:1.6 --- src/lib/libc/ssp/memcpy_chk.c:1.5 Tue Sep 16 20:39:28 2014 +++ src/lib/libc/ssp/memcpy_chk.c Sat May 9 11:42:21 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: memcpy_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $ */ +/* $NetBSD: memcpy_chk.c,v 1.6 2015/05/09 15:42:21 christos Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: memcpy_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $); +__RCSID($NetBSD: memcpy_chk.c,v 1.6 2015/05/09 15:42:21 christos Exp $); /*LINTLIBRARY*/ @@ -46,5 +46,9 @@ __memcpy_chk(void * __restrict dst, cons { if (len slen) __chk_fail(); + + if (__ssp_overlap(src, dst, len)) + __chk_fail(); + return memcpy(dst, src, len); } Index: src/lib/libc/ssp/stpcpy_chk.c diff -u src/lib/libc/ssp/stpcpy_chk.c:1.5 src/lib/libc/ssp/stpcpy_chk.c:1.6 --- src/lib/libc/ssp/stpcpy_chk.c:1.5 Sun Apr 6 15:29:25 2014 +++ src/lib/libc/ssp/stpcpy_chk.c Sat May 9 11:42:21 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: stpcpy_chk.c,v 1.5 2014/04/06 19:29:25 christos Exp $ */ +/* $NetBSD: stpcpy_chk.c,v 1.6 2015/05/09 15:42:21 christos Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: stpcpy_chk.c,v 1.5 2014/04/06 19:29:25 christos Exp $); +__RCSID($NetBSD: stpcpy_chk.c,v 1.6 2015/05/09 15:42:21 christos Exp $); /*LINTLIBRARY*/ @@ -50,6 +50,9 @@ __stpcpy_chk(char * __restrict dst, cons if (len = slen) __chk_fail(); + if (__ssp_overlap(src, dst, len)) + __chk_fail(); + (void)memcpy(dst, src, len + 1); return dst + len; } Index: src/lib/libc/ssp/strncpy_chk.c diff -u src/lib/libc/ssp/strncpy_chk.c:1.5 src/lib/libc/ssp/strncpy_chk.c:1.6 --- src/lib/libc/ssp/strncpy_chk.c:1.5 Tue Sep 16 20:39:28 2014 +++ src/lib/libc/ssp/strncpy_chk.c Sat May 9 11:42:21 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: strncpy_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $ */ +/* $NetBSD: strncpy_chk.c,v 1.6 2015/05/09 15:42:21 christos Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: strncpy_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $); +__RCSID($NetBSD: strncpy_chk.c,v 1.6 2015/05/09 15:42:21 christos Exp $); /*LINTLIBRARY*/ @@ -48,5 +48,8 @@ __strncpy_chk(char * __restrict dst, con if (len slen) __chk_fail(); + if (__ssp_overlap(src, dst, len)) + __chk_fail(); + return strncpy(dst, src, len); } Index: src/lib/libc/ssp/stpncpy_chk.c diff -u src/lib/libc/ssp/stpncpy_chk.c:1.2 src/lib/libc/ssp/stpncpy_chk.c:1.3 --- src/lib/libc/ssp/stpncpy_chk.c:1.2 Wed Nov 6 11:58:58 2013 +++ src/lib/libc/ssp/stpncpy_chk.c Sat May 9 11:42:21 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: stpncpy_chk.c,v 1.2 2013/11/06 16:58:58 christos Exp $ */ +/* $NetBSD: stpncpy_chk.c,v 1.3 2015/05/09 15:42:21 christos Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: stpncpy_chk.c,v 1.2 2013/11/06 16:58:58 christos Exp $); +__RCSID($NetBSD: stpncpy_chk.c,v 1.3 2015/05/09 15:42:21 christos Exp $); /*LINTLIBRARY*/ @@ -49,5 +49,8 @@ __stpncpy_chk(char * __restrict dst, con if (len slen) __chk_fail(); + if (__ssp_overlap(src, dst, len)) + __chk_fail(); + return stpncpy(dst, src, len); } Index: src/lib/libc/ssp/strcpy_chk.c diff -u src/lib/libc/ssp/strcpy_chk.c:1.7 src/lib/libc/ssp/strcpy_chk.c:1.8 --- src/lib/libc/ssp/strcpy_chk.c:1.7 Tue Sep 16 20:39:28 2014 +++ src/lib/libc/ssp/strcpy_chk.c Sat May 9 11:42:21 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: strcpy_chk.c,v 1.7 2014/09/17 00:39:28 joerg Exp $ */ +/* $NetBSD: strcpy_chk.c,v 1.8 2015/05/09 15:42:21 christos Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: strcpy_chk.c,v 1.7 2014/09/17 00:39:28 joerg Exp $); +__RCSID($NetBSD: strcpy_chk.c,v 1.8 2015/05/09 15:42:21 christos Exp $); /*LINTLIBRARY*/ @@ -48,5 +48,8 @@ __strcpy_chk(char * __restrict dst, cons if (len slen) __chk_fail();
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: joerg Date: Wed Sep 17 00:39:29 UTC 2014 Modified Files: src/lib/libc/ssp: memcpy_chk.c memmove_chk.c memset_chk.c strcat_chk.c strcpy_chk.c strncat_chk.c strncpy_chk.c Log Message: Provide explicit prototypes in case HAVE_SSP=no. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/lib/libc/ssp/memcpy_chk.c \ src/lib/libc/ssp/memmove_chk.c src/lib/libc/ssp/memset_chk.c \ src/lib/libc/ssp/strcat_chk.c src/lib/libc/ssp/strncat_chk.c \ src/lib/libc/ssp/strncpy_chk.c cvs rdiff -u -r1.6 -r1.7 src/lib/libc/ssp/strcpy_chk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/memcpy_chk.c diff -u src/lib/libc/ssp/memcpy_chk.c:1.4 src/lib/libc/ssp/memcpy_chk.c:1.5 --- src/lib/libc/ssp/memcpy_chk.c:1.4 Mon Apr 28 20:23:00 2008 +++ src/lib/libc/ssp/memcpy_chk.c Wed Sep 17 00:39:28 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: memcpy_chk.c,v 1.4 2008/04/28 20:23:00 martin Exp $ */ +/* $NetBSD: memcpy_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: memcpy_chk.c,v 1.4 2008/04/28 20:23:00 martin Exp $); +__RCSID($NetBSD: memcpy_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $); /*LINTLIBRARY*/ @@ -38,6 +38,8 @@ __RCSID($NetBSD: memcpy_chk.c,v 1.4 200 #undef memcpy +void *__memcpy_chk(void * __restrict, const void * __restrict, size_t, size_t); + void * __memcpy_chk(void * __restrict dst, const void * __restrict src, size_t len, size_t slen) Index: src/lib/libc/ssp/memmove_chk.c diff -u src/lib/libc/ssp/memmove_chk.c:1.4 src/lib/libc/ssp/memmove_chk.c:1.5 --- src/lib/libc/ssp/memmove_chk.c:1.4 Mon Apr 28 20:23:00 2008 +++ src/lib/libc/ssp/memmove_chk.c Wed Sep 17 00:39:28 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: memmove_chk.c,v 1.4 2008/04/28 20:23:00 martin Exp $ */ +/* $NetBSD: memmove_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: memmove_chk.c,v 1.4 2008/04/28 20:23:00 martin Exp $); +__RCSID($NetBSD: memmove_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $); /*LINTLIBRARY*/ @@ -38,6 +38,8 @@ __RCSID($NetBSD: memmove_chk.c,v 1.4 20 #undef memmove +void *__memmove_chk(void *, void *src, size_t, size_t); + void * __memmove_chk(void *dst, void *src, size_t len, size_t slen) Index: src/lib/libc/ssp/memset_chk.c diff -u src/lib/libc/ssp/memset_chk.c:1.4 src/lib/libc/ssp/memset_chk.c:1.5 --- src/lib/libc/ssp/memset_chk.c:1.4 Mon Apr 28 20:23:00 2008 +++ src/lib/libc/ssp/memset_chk.c Wed Sep 17 00:39:28 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: memset_chk.c,v 1.4 2008/04/28 20:23:00 martin Exp $ */ +/* $NetBSD: memset_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: memset_chk.c,v 1.4 2008/04/28 20:23:00 martin Exp $); +__RCSID($NetBSD: memset_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $); /*LINTLIBRARY*/ @@ -38,6 +38,8 @@ __RCSID($NetBSD: memset_chk.c,v 1.4 200 #undef memset +void *__memset_chk(void * __restrict, int, size_t, size_t); + void * __memset_chk(void * __restrict dst, int val, size_t len, size_t slen) { Index: src/lib/libc/ssp/strcat_chk.c diff -u src/lib/libc/ssp/strcat_chk.c:1.4 src/lib/libc/ssp/strcat_chk.c:1.5 --- src/lib/libc/ssp/strcat_chk.c:1.4 Tue Nov 17 20:44:26 2009 +++ src/lib/libc/ssp/strcat_chk.c Wed Sep 17 00:39:28 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: strcat_chk.c,v 1.4 2009/11/17 20:44:26 drochner Exp $ */ +/* $NetBSD: strcat_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -29,13 +29,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: strcat_chk.c,v 1.4 2009/11/17 20:44:26 drochner Exp $); +__RCSID($NetBSD: strcat_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $); /*LINTLIBRARY*/ #include ssp/ssp.h #include string.h +char *__strcat_chk(char * __restrict, const char * __restrict, size_t); + char * __strcat_chk(char * __restrict dst, const char * __restrict src, size_t slen) { Index: src/lib/libc/ssp/strncat_chk.c diff -u src/lib/libc/ssp/strncat_chk.c:1.4 src/lib/libc/ssp/strncat_chk.c:1.5 --- src/lib/libc/ssp/strncat_chk.c:1.4 Tue Nov 17 20:44:26 2009 +++ src/lib/libc/ssp/strncat_chk.c Wed Sep 17 00:39:28 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: strncat_chk.c,v 1.4 2009/11/17 20:44:26 drochner Exp $ */ +/* $NetBSD: strncat_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: strncat_chk.c,v 1.4 2009/11/17 20:44:26
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: christos Date: Sun Apr 6 19:29:25 UTC 2014 Modified Files: src/lib/libc/ssp: stpcpy_chk.c Log Message: fix incorrect bounds check To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/lib/libc/ssp/stpcpy_chk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/stpcpy_chk.c diff -u src/lib/libc/ssp/stpcpy_chk.c:1.4 src/lib/libc/ssp/stpcpy_chk.c:1.5 --- src/lib/libc/ssp/stpcpy_chk.c:1.4 Sat Apr 5 21:13:59 2014 +++ src/lib/libc/ssp/stpcpy_chk.c Sun Apr 6 15:29:25 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: stpcpy_chk.c,v 1.4 2014/04/06 01:13:59 christos Exp $ */ +/* $NetBSD: stpcpy_chk.c,v 1.5 2014/04/06 19:29:25 christos Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: stpcpy_chk.c,v 1.4 2014/04/06 01:13:59 christos Exp $); +__RCSID($NetBSD: stpcpy_chk.c,v 1.5 2014/04/06 19:29:25 christos Exp $); /*LINTLIBRARY*/ @@ -45,11 +45,11 @@ char *__stpcpy_chk(char * __restrict, co char * __stpcpy_chk(char * __restrict dst, const char * __restrict src, size_t slen) { - size_t len = strlen(src) + 1; + size_t len = strlen(src); - if (len slen) + if (len = slen) __chk_fail(); - (void)memcpy(dst, src, len); - return dst + len - 1; + (void)memcpy(dst, src, len + 1); + return dst + len; }
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: christos Date: Sun Apr 6 19:29:37 UTC 2014 Modified Files: src/lib/libc/ssp: Makefile.inc Log Message: add __stpncpy_chk To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/lib/libc/ssp/Makefile.inc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/Makefile.inc diff -u src/lib/libc/ssp/Makefile.inc:1.4 src/lib/libc/ssp/Makefile.inc:1.5 --- src/lib/libc/ssp/Makefile.inc:1.4 Wed Nov 6 21:01:42 2013 +++ src/lib/libc/ssp/Makefile.inc Sun Apr 6 15:29:37 2014 @@ -1,9 +1,9 @@ -# $NetBSD: Makefile.inc,v 1.4 2013/11/07 02:01:42 christos Exp $ +# $NetBSD: Makefile.inc,v 1.5 2014/04/06 19:29:37 christos Exp $ .PATH: ${.CURDIR}/ssp SSP_SRCS= gets_chk.c fgets_chk.c memcpy_chk.c memmove_chk.c memset_chk.c \ - snprintf_chk.c sprintf_chk.c stpcpy_chk.c \ + snprintf_chk.c sprintf_chk.c stpcpy_chk.c stpncpy_chk.c \ strcat_chk.c strcpy_chk.c strncat_chk.c strncpy_chk.c \ vsnprintf_chk.c vsprintf_chk.c
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: christos Date: Sun Apr 6 01:01:49 UTC 2014 Modified Files: src/lib/libc/ssp: stpcpy_chk.c Log Message: fix off by one in stpcpy_chk. christos To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/lib/libc/ssp/stpcpy_chk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/stpcpy_chk.c diff -u src/lib/libc/ssp/stpcpy_chk.c:1.2 src/lib/libc/ssp/stpcpy_chk.c:1.3 --- src/lib/libc/ssp/stpcpy_chk.c:1.2 Wed Nov 6 11:58:58 2013 +++ src/lib/libc/ssp/stpcpy_chk.c Sat Apr 5 21:01:49 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: stpcpy_chk.c,v 1.2 2013/11/06 16:58:58 christos Exp $ */ +/* $NetBSD: stpcpy_chk.c,v 1.3 2014/04/06 01:01:49 christos Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: stpcpy_chk.c,v 1.2 2013/11/06 16:58:58 christos Exp $); +__RCSID($NetBSD: stpcpy_chk.c,v 1.3 2014/04/06 01:01:49 christos Exp $); /*LINTLIBRARY*/ @@ -45,11 +45,11 @@ char *__stpcpy_chk(char * __restrict, co char * __stpcpy_chk(char * __restrict dst, const char * __restrict src, size_t slen) { - size_t len = strlen(src) + 1; + size_t len = strlen(src); if (len slen) __chk_fail(); - (void)memcpy(dst, src, len); + (void)memcpy(dst, src, len + 1); return dst + len; }
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: christos Date: Sun Apr 6 01:13:59 UTC 2014 Modified Files: src/lib/libc/ssp: stpcpy_chk.c Log Message: fix the limit check. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/lib/libc/ssp/stpcpy_chk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/stpcpy_chk.c diff -u src/lib/libc/ssp/stpcpy_chk.c:1.3 src/lib/libc/ssp/stpcpy_chk.c:1.4 --- src/lib/libc/ssp/stpcpy_chk.c:1.3 Sat Apr 5 21:01:49 2014 +++ src/lib/libc/ssp/stpcpy_chk.c Sat Apr 5 21:13:59 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: stpcpy_chk.c,v 1.3 2014/04/06 01:01:49 christos Exp $ */ +/* $NetBSD: stpcpy_chk.c,v 1.4 2014/04/06 01:13:59 christos Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: stpcpy_chk.c,v 1.3 2014/04/06 01:01:49 christos Exp $); +__RCSID($NetBSD: stpcpy_chk.c,v 1.4 2014/04/06 01:13:59 christos Exp $); /*LINTLIBRARY*/ @@ -45,11 +45,11 @@ char *__stpcpy_chk(char * __restrict, co char * __stpcpy_chk(char * __restrict dst, const char * __restrict src, size_t slen) { - size_t len = strlen(src); + size_t len = strlen(src) + 1; if (len slen) __chk_fail(); - (void)memcpy(dst, src, len + 1); - return dst + len; + (void)memcpy(dst, src, len); + return dst + len - 1; }
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: christos Date: Wed Nov 6 16:30:27 UTC 2013 Modified Files: src/lib/libc/ssp: strcpy_chk.c Log Message: simplify To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/lib/libc/ssp/strcpy_chk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/strcpy_chk.c diff -u src/lib/libc/ssp/strcpy_chk.c:1.5 src/lib/libc/ssp/strcpy_chk.c:1.6 --- src/lib/libc/ssp/strcpy_chk.c:1.5 Tue Dec 28 11:19:25 2010 +++ src/lib/libc/ssp/strcpy_chk.c Wed Nov 6 11:30:27 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: strcpy_chk.c,v 1.5 2010/12/28 16:19:25 christos Exp $ */ +/* $NetBSD: strcpy_chk.c,v 1.6 2013/11/06 16:30:27 christos Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: strcpy_chk.c,v 1.5 2010/12/28 16:19:25 christos Exp $); +__RCSID($NetBSD: strcpy_chk.c,v 1.6 2013/11/06 16:30:27 christos Exp $); /*LINTLIBRARY*/ @@ -41,10 +41,10 @@ __RCSID($NetBSD: strcpy_chk.c,v 1.5 201 char * __strcpy_chk(char * __restrict dst, const char * __restrict src, size_t slen) { - size_t len = strlen(src); + size_t len = strlen(src) + 1; - if (len = slen) + if (len slen) __chk_fail(); - return memcpy(dst, src, len + 1); + return memcpy(dst, src, len); }
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: christos Date: Wed Nov 6 16:30:55 UTC 2013 Modified Files: src/lib/libc/ssp: ssp.3 Log Message: fix doc for strcpy, strcat add stp{,n}cpy To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/lib/libc/ssp/ssp.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/ssp.3 diff -u src/lib/libc/ssp/ssp.3:1.6 src/lib/libc/ssp/ssp.3:1.7 --- src/lib/libc/ssp/ssp.3:1.6 Mon Mar 21 00:42:50 2011 +++ src/lib/libc/ssp/ssp.3 Wed Nov 6 11:30:55 2013 @@ -1,4 +1,4 @@ -.\ $NetBSD: ssp.3,v 1.6 2011/03/21 04:42:50 jruoho Exp $ +.\ $NetBSD: ssp.3,v 1.7 2013/11/06 16:30:55 christos Exp $ .\ .\ Copyright (c) 2007 The NetBSD Foundation, Inc. .\ All rights reserved. @@ -28,7 +28,7 @@ .\ POSSIBILITY OF SUCH DAMAGE. .\ .\ -.Dd March 21, 2011 +.Dd November 6, 2013 .Dt SSP 3 .Os .Sh NAME @@ -58,9 +58,13 @@ .Ft void * .Fn memset void *str int val size_t len .Ft char * -.Fn strcpy char *str const char *ptr size_t len +.Fn stpcpy char *str const char *ptr .Ft char * -.Fn strcat char *str const char *ptr size_t len +.Fn stpncpy char *str const char *ptr size_t len +.Ft char * +.Fn strcpy char *str const char *ptr +.Ft char * +.Fn strcat char *str const char *ptr .Ft char * .Fn strncpy char *str const char *ptr size_t len .Ft char *
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: christos Date: Wed Nov 6 16:31:08 UTC 2013 Modified Files: src/lib/libc/ssp: Makefile.inc Added Files: src/lib/libc/ssp: stpcpy_chk.c stpncpy_chk.c Log Message: add stp{,n}cpy To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/lib/libc/ssp/Makefile.inc cvs rdiff -u -r0 -r1.1 src/lib/libc/ssp/stpcpy_chk.c \ src/lib/libc/ssp/stpncpy_chk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/Makefile.inc diff -u src/lib/libc/ssp/Makefile.inc:1.2 src/lib/libc/ssp/Makefile.inc:1.3 --- src/lib/libc/ssp/Makefile.inc:1.2 Wed May 30 17:14:35 2007 +++ src/lib/libc/ssp/Makefile.inc Wed Nov 6 11:31:08 2013 @@ -1,10 +1,11 @@ -# $NetBSD: Makefile.inc,v 1.2 2007/05/30 21:14:35 tls Exp $ +# $NetBSD: Makefile.inc,v 1.3 2013/11/06 16:31:08 christos Exp $ .PATH: ${.CURDIR}/ssp SSP_SRCS= gets_chk.c fgets_chk.c memcpy_chk.c memmove_chk.c memset_chk.c \ - snprintf_chk.c sprintf_chk.c strcat_chk.c strcpy_chk.c \ - strncat_chk.c strncpy_chk.c vsnprintf_chk.c vsprintf_chk.c + snprintf_chk.c sprintf_chk.c stpcpy_chk.c stpncpy_chk.c \ + strcat_chk.c strcpy_chk.c strncat_chk.c strncpy_chk.c \ + vsnprintf_chk.c vsprintf_chk.c .for i in ${SSP_SRCS} SRCS+=${i} Added files: Index: src/lib/libc/ssp/stpcpy_chk.c diff -u /dev/null src/lib/libc/ssp/stpcpy_chk.c:1.1 --- /dev/null Wed Nov 6 11:31:08 2013 +++ src/lib/libc/ssp/stpcpy_chk.c Wed Nov 6 11:31:08 2013 @@ -0,0 +1,51 @@ +/* $NetBSD: stpcpy_chk.c,v 1.1 2013/11/06 16:31:08 christos Exp $ */ + +/*- + * Copyright (c) 2013 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 +__RCSID($NetBSD: stpcpy_chk.c,v 1.1 2013/11/06 16:31:08 christos Exp $); + +/*LINTLIBRARY*/ + +#include ssp/ssp.h +#include string.h + +#undef memcpy + +char * +__stpcpy_chk(char * __restrict dst, const char * __restrict src, size_t slen) +{ + size_t len = strlen(src) + 1; + + if (len slen) + __chk_fail(); + + (void)memcpy(dst, src, len); + return dst + len; +} Index: src/lib/libc/ssp/stpncpy_chk.c diff -u /dev/null src/lib/libc/ssp/stpncpy_chk.c:1.1 --- /dev/null Wed Nov 6 11:31:08 2013 +++ src/lib/libc/ssp/stpncpy_chk.c Wed Nov 6 11:31:08 2013 @@ -0,0 +1,49 @@ +/* $NetBSD: stpncpy_chk.c,v 1.1 2013/11/06 16:31:08 christos Exp $ */ + +/*- + * Copyright (c) 2013 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: christos Date: Wed Nov 6 16:58:58 UTC 2013 Modified Files: src/lib/libc/ssp: stpcpy_chk.c stpncpy_chk.c Log Message: handle old gcc To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/lib/libc/ssp/stpcpy_chk.c \ src/lib/libc/ssp/stpncpy_chk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/stpcpy_chk.c diff -u src/lib/libc/ssp/stpcpy_chk.c:1.1 src/lib/libc/ssp/stpcpy_chk.c:1.2 --- src/lib/libc/ssp/stpcpy_chk.c:1.1 Wed Nov 6 11:31:08 2013 +++ src/lib/libc/ssp/stpcpy_chk.c Wed Nov 6 11:58:58 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: stpcpy_chk.c,v 1.1 2013/11/06 16:31:08 christos Exp $ */ +/* $NetBSD: stpcpy_chk.c,v 1.2 2013/11/06 16:58:58 christos Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: stpcpy_chk.c,v 1.1 2013/11/06 16:31:08 christos Exp $); +__RCSID($NetBSD: stpcpy_chk.c,v 1.2 2013/11/06 16:58:58 christos Exp $); /*LINTLIBRARY*/ @@ -38,6 +38,10 @@ __RCSID($NetBSD: stpcpy_chk.c,v 1.1 201 #undef memcpy +#if !__GNUC_PREREQ__(4, 8) +char *__stpcpy_chk(char * __restrict, const char * __restrict, size_t); +#endif + char * __stpcpy_chk(char * __restrict dst, const char * __restrict src, size_t slen) { Index: src/lib/libc/ssp/stpncpy_chk.c diff -u src/lib/libc/ssp/stpncpy_chk.c:1.1 src/lib/libc/ssp/stpncpy_chk.c:1.2 --- src/lib/libc/ssp/stpncpy_chk.c:1.1 Wed Nov 6 11:31:08 2013 +++ src/lib/libc/ssp/stpncpy_chk.c Wed Nov 6 11:58:58 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: stpncpy_chk.c,v 1.1 2013/11/06 16:31:08 christos Exp $ */ +/* $NetBSD: stpncpy_chk.c,v 1.2 2013/11/06 16:58:58 christos Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: stpncpy_chk.c,v 1.1 2013/11/06 16:31:08 christos Exp $); +__RCSID($NetBSD: stpncpy_chk.c,v 1.2 2013/11/06 16:58:58 christos Exp $); /*LINTLIBRARY*/ @@ -38,6 +38,10 @@ __RCSID($NetBSD: stpncpy_chk.c,v 1.1 20 #undef stpncpy +#if !__GNUC_PREREQ__(4, 8) +char *__stpncpy_chk(char * __restrict, const char * __restrict, size_t, size_t); +#endif + char * __stpncpy_chk(char * __restrict dst, const char * __restrict src, size_t len, size_t slen)
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: christos Date: Thu Nov 7 02:01:42 UTC 2013 Modified Files: src/lib/libc/ssp: Makefile.inc ssp.3 Log Message: we don't support stpncpy until gcc does To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/lib/libc/ssp/Makefile.inc cvs rdiff -u -r1.7 -r1.8 src/lib/libc/ssp/ssp.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/Makefile.inc diff -u src/lib/libc/ssp/Makefile.inc:1.3 src/lib/libc/ssp/Makefile.inc:1.4 --- src/lib/libc/ssp/Makefile.inc:1.3 Wed Nov 6 11:31:08 2013 +++ src/lib/libc/ssp/Makefile.inc Wed Nov 6 21:01:42 2013 @@ -1,9 +1,9 @@ -# $NetBSD: Makefile.inc,v 1.3 2013/11/06 16:31:08 christos Exp $ +# $NetBSD: Makefile.inc,v 1.4 2013/11/07 02:01:42 christos Exp $ .PATH: ${.CURDIR}/ssp SSP_SRCS= gets_chk.c fgets_chk.c memcpy_chk.c memmove_chk.c memset_chk.c \ - snprintf_chk.c sprintf_chk.c stpcpy_chk.c stpncpy_chk.c \ + snprintf_chk.c sprintf_chk.c stpcpy_chk.c \ strcat_chk.c strcpy_chk.c strncat_chk.c strncpy_chk.c \ vsnprintf_chk.c vsprintf_chk.c Index: src/lib/libc/ssp/ssp.3 diff -u src/lib/libc/ssp/ssp.3:1.7 src/lib/libc/ssp/ssp.3:1.8 --- src/lib/libc/ssp/ssp.3:1.7 Wed Nov 6 11:30:55 2013 +++ src/lib/libc/ssp/ssp.3 Wed Nov 6 21:01:42 2013 @@ -1,4 +1,4 @@ -.\ $NetBSD: ssp.3,v 1.7 2013/11/06 16:30:55 christos Exp $ +.\ $NetBSD: ssp.3,v 1.8 2013/11/07 02:01:42 christos Exp $ .\ .\ Copyright (c) 2007 The NetBSD Foundation, Inc. .\ All rights reserved. @@ -60,8 +60,6 @@ .Ft char * .Fn stpcpy char *str const char *ptr .Ft char * -.Fn stpncpy char *str const char *ptr size_t len -.Ft char * .Fn strcpy char *str const char *ptr .Ft char * .Fn strcat char *str const char *ptr
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: wiz Date: Thu Jul 19 06:44:12 UTC 2012 Modified Files: src/lib/libc/ssp: __builtin_object_size.3 Log Message: Minus (one) needs a backslash before the minus. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/lib/libc/ssp/__builtin_object_size.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/__builtin_object_size.3 diff -u src/lib/libc/ssp/__builtin_object_size.3:1.9 src/lib/libc/ssp/__builtin_object_size.3:1.10 --- src/lib/libc/ssp/__builtin_object_size.3:1.9 Wed Jul 18 22:22:26 2012 +++ src/lib/libc/ssp/__builtin_object_size.3 Thu Jul 19 06:44:12 2012 @@ -1,4 +1,4 @@ -.\ $NetBSD: __builtin_object_size.3,v 1.9 2012/07/18 22:22:26 christos Exp $ +.\ $NetBSD: __builtin_object_size.3,v 1.10 2012/07/19 06:44:12 wiz Exp $ .\ .\ Copyright (c) 2007 The NetBSD Foundation, Inc. .\ All rights reserved. @@ -50,8 +50,8 @@ effects. If the size of the object is not known or it has side effects the .Fn __builtin_object_size function returns: -.Bl -tag -width (size_t)-1 -offset indent -.It Dv (size_t)-1 +.Bl -tag -width (size_t)\-1 -offset indent +.It Dv (size_t)\-1 for .Fa type .Dv 0 @@ -90,7 +90,7 @@ appeared in This is a non-standard, compiler-specific extension. .Pp Note that currently the object size calculation pass is only done at -O1 -or above, meaning that this function always returns -1 when the optimizer +or above, meaning that this function always returns \-1 when the optimizer is off. .Pp There are some discussions about always doing the object size pass, but
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: christos Date: Wed Jul 18 22:22:26 UTC 2012 Modified Files: src/lib/libc/ssp: __builtin_object_size.3 Log Message: Explain what's going on with fortify being disabled when the optimizer is off: http://gcc.gnu.org/ml/gcc-patches/2012-06/msg00174.html To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/lib/libc/ssp/__builtin_object_size.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/__builtin_object_size.3 diff -u src/lib/libc/ssp/__builtin_object_size.3:1.8 src/lib/libc/ssp/__builtin_object_size.3:1.9 --- src/lib/libc/ssp/__builtin_object_size.3:1.8 Sun Dec 19 04:33:52 2010 +++ src/lib/libc/ssp/__builtin_object_size.3 Wed Jul 18 18:22:26 2012 @@ -1,4 +1,4 @@ -.\ $NetBSD: __builtin_object_size.3,v 1.8 2010/12/19 09:33:52 jruoho Exp $ +.\ $NetBSD: __builtin_object_size.3,v 1.9 2012/07/18 22:22:26 christos Exp $ .\ .\ Copyright (c) 2007 The NetBSD Foundation, Inc. .\ All rights reserved. @@ -28,7 +28,7 @@ .\ POSSIBILITY OF SUCH DAMAGE. .\ .\ -.Dd December 19, 2010 +.Dd July 18, 2012 .Dt __BUILTIN_OBJECT_SIZE 3 .Os .Sh NAME @@ -88,3 +88,14 @@ appeared in .Tn GCC 4.1 . .Sh CAVEATS This is a non-standard, compiler-specific extension. +.Pp +Note that currently the object size calculation pass is only done at -O1 +or above, meaning that this function always returns -1 when the optimizer +is off. +.Pp +There are some discussions about always doing the object size pass, but +the issue is that without the optimization pass data sizes are not going +to be correct. +.Pp +For that reason currently code fortification (size-checked replacement +functions) is disabled when optimization is off.
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: christos Date: Tue Dec 28 16:19:25 UTC 2010 Modified Files: src/lib/libc/ssp: strcpy_chk.c Log Message: off by one To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/lib/libc/ssp/strcpy_chk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/strcpy_chk.c diff -u src/lib/libc/ssp/strcpy_chk.c:1.4 src/lib/libc/ssp/strcpy_chk.c:1.5 --- src/lib/libc/ssp/strcpy_chk.c:1.4 Mon Apr 28 16:23:00 2008 +++ src/lib/libc/ssp/strcpy_chk.c Tue Dec 28 11:19:25 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: strcpy_chk.c,v 1.4 2008/04/28 20:23:00 martin Exp $ */ +/* $NetBSD: strcpy_chk.c,v 1.5 2010/12/28 16:19:25 christos Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: strcpy_chk.c,v 1.4 2008/04/28 20:23:00 martin Exp $); +__RCSID($NetBSD: strcpy_chk.c,v 1.5 2010/12/28 16:19:25 christos Exp $); /*LINTLIBRARY*/ @@ -43,7 +43,7 @@ { size_t len = strlen(src); - if (len slen) + if (len = slen) __chk_fail(); return memcpy(dst, src, len + 1);
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: jruoho Date: Sun Dec 19 08:21:36 UTC 2010 Modified Files: src/lib/libc/ssp: __builtin_object_size.3 Log Message: Fix SYNOPSIS, add CAVEATS. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/lib/libc/ssp/__builtin_object_size.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/__builtin_object_size.3 diff -u src/lib/libc/ssp/__builtin_object_size.3:1.6 src/lib/libc/ssp/__builtin_object_size.3:1.7 --- src/lib/libc/ssp/__builtin_object_size.3:1.6 Thu Dec 16 17:50:39 2010 +++ src/lib/libc/ssp/__builtin_object_size.3 Sun Dec 19 08:21:36 2010 @@ -1,4 +1,4 @@ -.\ $NetBSD: __builtin_object_size.3,v 1.6 2010/12/16 17:50:39 jruoho Exp $ +.\ $NetBSD: __builtin_object_size.3,v 1.7 2010/12/19 08:21:36 jruoho Exp $ .\ .\ Copyright (c) 2007 The NetBSD Foundation, Inc. .\ All rights reserved. @@ -28,13 +28,13 @@ .\ POSSIBILITY OF SUCH DAMAGE. .\ .\ -.Dd December 16, 2010 +.Dd December 19, 2010 .Dt __BUILTIN_OBJECT_SIZE 3 .Os .Sh NAME .Nm __builtin_object_size .Nd return the size of the given object -.Sh LIBRARY +.Sh SYNOPSIS .Ft size_t .Fn __builtin_object_size void *ptr int type .Sh DESCRIPTION @@ -85,3 +85,5 @@ .Fn __builtin_object_size appeared in .Tn GCC 4.1 . +.Sh CAVEATS +This is a non-standard, compiler-specific extension.
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: jruoho Date: Sun Dec 19 08:28:40 UTC 2010 Modified Files: src/lib/libc/ssp: ssp.3 Log Message: Small modifications to wording, tidy up SEE ALSO. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/lib/libc/ssp/ssp.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/ssp.3 diff -u src/lib/libc/ssp/ssp.3:1.4 src/lib/libc/ssp/ssp.3:1.5 --- src/lib/libc/ssp/ssp.3:1.4 Sun May 25 20:07:14 2008 +++ src/lib/libc/ssp/ssp.3 Sun Dec 19 08:28:40 2010 @@ -1,4 +1,4 @@ -.\ $NetBSD: ssp.3,v 1.4 2008/05/25 20:07:14 wiz Exp $ +.\ $NetBSD: ssp.3,v 1.5 2010/12/19 08:28:40 jruoho Exp $ .\ .\ Copyright (c) 2007 The NetBSD Foundation, Inc. .\ All rights reserved. @@ -28,7 +28,7 @@ .\ POSSIBILITY OF SUCH DAMAGE. .\ .\ -.Dd May 23, 2007 +.Dd December 19, 2010 .Dt SSP 3 .Os .Sh NAME @@ -82,13 +82,13 @@ .Dv _FORTIFY_SOURCE bounds checking is enabled as described below, the above functions get overwritten to use the -.Xr gcc 1 .Xr __builtin_object_size 3 function to compute the size of -.Fa str -if known at compile time and perform bounds check on it in order +.Fa str , +if known at compile time, +and perform bounds check on it in order to avoid data buffer or stack buffer overflows. -If an overflow is detected the routines will call +If an overflow is detected, the routines will call .Xr abort 3 . .Pp To enable these function overrides the following should be added to the @@ -110,13 +110,10 @@ it will compute the minimum buffer size. .Sh SEE ALSO .Xr gcc 1 , -.Xr read 2 , -.Xr readlink 2 , .Xr __builtin_object_size 3 , -.Xr abort 3 , -.Xr getcwd 3 , .Xr stdio 3 , -.Xr string 3 +.Xr string 3 , +.Xr security 8 .Sh HISTORY The .Nm ssp
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: jruoho Date: Sun Dec 19 09:33:52 UTC 2010 Modified Files: src/lib/libc/ssp: __builtin_object_size.3 Log Message: Xref __builtin_return_address(3). To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/lib/libc/ssp/__builtin_object_size.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/__builtin_object_size.3 diff -u src/lib/libc/ssp/__builtin_object_size.3:1.7 src/lib/libc/ssp/__builtin_object_size.3:1.8 --- src/lib/libc/ssp/__builtin_object_size.3:1.7 Sun Dec 19 08:21:36 2010 +++ src/lib/libc/ssp/__builtin_object_size.3 Sun Dec 19 09:33:52 2010 @@ -1,4 +1,4 @@ -.\ $NetBSD: __builtin_object_size.3,v 1.7 2010/12/19 08:21:36 jruoho Exp $ +.\ $NetBSD: __builtin_object_size.3,v 1.8 2010/12/19 09:33:52 jruoho Exp $ .\ .\ Copyright (c) 2007 The NetBSD Foundation, Inc. .\ All rights reserved. @@ -78,6 +78,7 @@ .Dv \*[Am] 2 != 0 . .Sh SEE ALSO .Xr gcc 1 , +.Xr __builtin_return_address 3 , .Xr attribute 3 , .Xr ssp 3 .Sh HISTORY
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: jruoho Date: Thu Apr 22 13:41:40 UTC 2010 Modified Files: src/lib/libc/ssp: __builtin_object_size.3 Log Message: gcc - GCC, offset indent. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/lib/libc/ssp/__builtin_object_size.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/__builtin_object_size.3 diff -u src/lib/libc/ssp/__builtin_object_size.3:1.4 src/lib/libc/ssp/__builtin_object_size.3:1.5 --- src/lib/libc/ssp/__builtin_object_size.3:1.4 Fri Jun 6 05:51:46 2008 +++ src/lib/libc/ssp/__builtin_object_size.3 Thu Apr 22 13:41:40 2010 @@ -1,4 +1,4 @@ -.\ $NetBSD: __builtin_object_size.3,v 1.4 2008/06/06 05:51:46 yamt Exp $ +.\ $NetBSD: __builtin_object_size.3,v 1.5 2010/04/22 13:41:40 jruoho Exp $ .\ .\ Copyright (c) 2007 The NetBSD Foundation, Inc. .\ All rights reserved. @@ -28,7 +28,7 @@ .\ POSSIBILITY OF SUCH DAMAGE. .\ .\ -.Dd May 23, 2007 +.Dd April 22, 2010 .Dt __BUILTIN_OBJECT_SIZE 3 .Os .Sh NAME @@ -50,7 +50,7 @@ If the size of the object is not known or it has side effects the .Fn __builtin_object_size function returns: -.Bl -tag -width (size_t)-1 +.Bl -tag -width (size_t)-1 -offset indent .It Dv (size_t)-1 for .Fa type @@ -82,4 +82,5 @@ .Sh HISTORY The .Fn __builtin_object_size -appeared in gcc 4.1. +appeared in +.Tn GCC 4.1 .
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: wiz Date: Sun Jan 17 23:13:32 UTC 2010 Modified Files: src/lib/libc/ssp: gets_chk.c Log Message: Free malloc()ed buffer in error case. Found by cppcheck. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/lib/libc/ssp/gets_chk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/gets_chk.c diff -u src/lib/libc/ssp/gets_chk.c:1.5 src/lib/libc/ssp/gets_chk.c:1.6 --- src/lib/libc/ssp/gets_chk.c:1.5 Mon Apr 28 20:23:00 2008 +++ src/lib/libc/ssp/gets_chk.c Sun Jan 17 23:13:32 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: gets_chk.c,v 1.5 2008/04/28 20:23:00 martin Exp $ */ +/* $NetBSD: gets_chk.c,v 1.6 2010/01/17 23:13:32 wiz Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: gets_chk.c,v 1.5 2008/04/28 20:23:00 martin Exp $); +__RCSID($NetBSD: gets_chk.c,v 1.6 2010/01/17 23:13:32 wiz Exp $); /*LINTLIBRARY*/ @@ -54,8 +54,10 @@ if ((abuf = malloc(slen + 1)) == NULL) return gets(buf); - if (fgets(abuf, (int)(slen + 1), stdin) == NULL) + if (fgets(abuf, (int)(slen + 1), stdin) == NULL) { + free(abuf); return NULL; + } len = strlen(abuf); if (len 0 abuf[len - 1] == '\n')
CVS commit: src/lib/libc/ssp
Module Name:src Committed By: drochner Date: Tue Nov 17 20:44:26 UTC 2009 Modified Files: src/lib/libc/ssp: strcat_chk.c strncat_chk.c Log Message: make the src strings const as in the unchecked equivalents To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/lib/libc/ssp/strcat_chk.c \ src/lib/libc/ssp/strncat_chk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/ssp/strcat_chk.c diff -u src/lib/libc/ssp/strcat_chk.c:1.3 src/lib/libc/ssp/strcat_chk.c:1.4 --- src/lib/libc/ssp/strcat_chk.c:1.3 Mon Apr 28 20:23:00 2008 +++ src/lib/libc/ssp/strcat_chk.c Tue Nov 17 20:44:26 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: strcat_chk.c,v 1.3 2008/04/28 20:23:00 martin Exp $ */ +/* $NetBSD: strcat_chk.c,v 1.4 2009/11/17 20:44:26 drochner Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: strcat_chk.c,v 1.3 2008/04/28 20:23:00 martin Exp $); +__RCSID($NetBSD: strcat_chk.c,v 1.4 2009/11/17 20:44:26 drochner Exp $); /*LINTLIBRARY*/ @@ -37,7 +37,7 @@ #include string.h char * -__strcat_chk(char * __restrict dst, char * __restrict src, size_t slen) +__strcat_chk(char * __restrict dst, const char * __restrict src, size_t slen) { char *d; Index: src/lib/libc/ssp/strncat_chk.c diff -u src/lib/libc/ssp/strncat_chk.c:1.3 src/lib/libc/ssp/strncat_chk.c:1.4 --- src/lib/libc/ssp/strncat_chk.c:1.3 Mon Apr 28 20:23:00 2008 +++ src/lib/libc/ssp/strncat_chk.c Tue Nov 17 20:44:26 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: strncat_chk.c,v 1.3 2008/04/28 20:23:00 martin Exp $ */ +/* $NetBSD: strncat_chk.c,v 1.4 2009/11/17 20:44:26 drochner Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include sys/cdefs.h -__RCSID($NetBSD: strncat_chk.c,v 1.3 2008/04/28 20:23:00 martin Exp $); +__RCSID($NetBSD: strncat_chk.c,v 1.4 2009/11/17 20:44:26 drochner Exp $); /*LINTLIBRARY*/ @@ -38,7 +38,7 @@ #include stdio.h char * -__strncat_chk(char * __restrict dst, char * __restrict src, size_t len, +__strncat_chk(char * __restrict dst, const char * __restrict src, size_t len, size_t slen) { char *d;