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 off by one in stpcpy_chk.



details:   https://anonhg.NetBSD.org/src/rev/d73c3c390529
branches:  trunk
changeset: 328529:d73c3c390529
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Apr 06 01:01:49 2014 +0000

description:
fix off by one in stpcpy_chk.

christos

diffstat:

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

diffs (32 lines):

diff -r 58ff27c73e64 -r d73c3c390529 lib/libc/ssp/stpcpy_chk.c
--- a/lib/libc/ssp/stpcpy_chk.c Sun Apr 06 00:56:39 2014 +0000
+++ b/lib/libc/ssp/stpcpy_chk.c Sun Apr 06 01:01:49 2014 +0000
@@ -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 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;
 }



Home | Main Index | Thread Index | Old Index