Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/ssp fix incorrect bounds check



details:   https://anonhg.NetBSD.org/src/rev/ebe36b766040
branches:  trunk
changeset: 328550:ebe36b766040
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Apr 06 19:29:25 2014 +0000

description:
fix incorrect bounds check

diffstat:

 lib/libc/ssp/stpcpy_chk.c |  12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diffs (34 lines):

diff -r f4689ae9b5e8 -r ebe36b766040 lib/libc/ssp/stpcpy_chk.c
--- a/lib/libc/ssp/stpcpy_chk.c Sun Apr 06 19:28:59 2014 +0000
+++ b/lib/libc/ssp/stpcpy_chk.c Sun Apr 06 19:29:25 2014 +0000
@@ -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 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;
 }



Home | Main Index | Thread Index | Old Index