Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/ssp add overlapping pointer checks
details: https://anonhg.NetBSD.org/src/rev/27536524637a
branches: trunk
changeset: 338061:27536524637a
user: christos <christos%NetBSD.org@localhost>
date: Sat May 09 15:42:21 2015 +0000
description:
add overlapping pointer checks
diffstat:
lib/libc/ssp/memcpy_chk.c | 8 ++++++--
lib/libc/ssp/stpcpy_chk.c | 7 +++++--
lib/libc/ssp/stpncpy_chk.c | 7 +++++--
lib/libc/ssp/strcpy_chk.c | 7 +++++--
lib/libc/ssp/strncpy_chk.c | 7 +++++--
5 files changed, 26 insertions(+), 10 deletions(-)
diffs (137 lines):
diff -r 91cf9c12e9d5 -r 27536524637a lib/libc/ssp/memcpy_chk.c
--- a/lib/libc/ssp/memcpy_chk.c Sat May 09 15:41:47 2015 +0000
+++ b/lib/libc/ssp/memcpy_chk.c Sat May 09 15:42:21 2015 +0000
@@ -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 @@
{
if (len > slen)
__chk_fail();
+
+ if (__ssp_overlap(src, dst, len))
+ __chk_fail();
+
return memcpy(dst, src, len);
}
diff -r 91cf9c12e9d5 -r 27536524637a lib/libc/ssp/stpcpy_chk.c
--- a/lib/libc/ssp/stpcpy_chk.c Sat May 09 15:41:47 2015 +0000
+++ b/lib/libc/ssp/stpcpy_chk.c Sat May 09 15:42:21 2015 +0000
@@ -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 @@
if (len >= slen)
__chk_fail();
+ if (__ssp_overlap(src, dst, len))
+ __chk_fail();
+
(void)memcpy(dst, src, len + 1);
return dst + len;
}
diff -r 91cf9c12e9d5 -r 27536524637a lib/libc/ssp/stpncpy_chk.c
--- a/lib/libc/ssp/stpncpy_chk.c Sat May 09 15:41:47 2015 +0000
+++ b/lib/libc/ssp/stpncpy_chk.c Sat May 09 15:42:21 2015 +0000
@@ -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 @@
if (len > slen)
__chk_fail();
+ if (__ssp_overlap(src, dst, len))
+ __chk_fail();
+
return stpncpy(dst, src, len);
}
diff -r 91cf9c12e9d5 -r 27536524637a lib/libc/ssp/strcpy_chk.c
--- a/lib/libc/ssp/strcpy_chk.c Sat May 09 15:41:47 2015 +0000
+++ b/lib/libc/ssp/strcpy_chk.c Sat May 09 15:42:21 2015 +0000
@@ -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 @@
if (len > slen)
__chk_fail();
+ if (__ssp_overlap(src, dst, len))
+ __chk_fail();
+
return memcpy(dst, src, len);
}
diff -r 91cf9c12e9d5 -r 27536524637a lib/libc/ssp/strncpy_chk.c
--- a/lib/libc/ssp/strncpy_chk.c Sat May 09 15:41:47 2015 +0000
+++ b/lib/libc/ssp/strncpy_chk.c Sat May 09 15:42:21 2015 +0000
@@ -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 @@
if (len > slen)
__chk_fail();
+ if (__ssp_overlap(src, dst, len))
+ __chk_fail();
+
return strncpy(dst, src, len);
}
Home |
Main Index |
Thread Index |
Old Index