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 the limit check.



details:   https://anonhg.NetBSD.org/src/rev/5d238f973dc7
branches:  trunk
changeset: 328530:5d238f973dc7
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Apr 06 01:13:59 2014 +0000

description:
fix the limit check.

diffstat:

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

diffs (33 lines):

diff -r d73c3c390529 -r 5d238f973dc7 lib/libc/ssp/stpcpy_chk.c
--- a/lib/libc/ssp/stpcpy_chk.c Sun Apr 06 01:01:49 2014 +0000
+++ b/lib/libc/ssp/stpcpy_chk.c Sun Apr 06 01:13:59 2014 +0000
@@ -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 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;
 }



Home | Main Index | Thread Index | Old Index