Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/string overlapping strcpy is UB. use memmove



details:   https://anonhg.NetBSD.org/src/rev/83b694ae6467
branches:  trunk
changeset: 821665:83b694ae6467
user:      maya <maya%NetBSD.org@localhost>
date:      Sun Feb 12 17:19:00 2017 +0000

description:
overlapping strcpy is UB. use memmove
from asan+ubsan

diffstat:

 lib/libc/string/stresep.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r e5eefe97230e -r 83b694ae6467 lib/libc/string/stresep.c
--- a/lib/libc/string/stresep.c Sun Feb 12 16:54:06 2017 +0000
+++ b/lib/libc/string/stresep.c Sun Feb 12 17:19:00 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: stresep.c,v 1.2 2007/12/06 22:07:07 seb Exp $  */
+/*     $NetBSD: stresep.c,v 1.3 2017/02/12 17:19:00 maya Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)strsep.c   8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: stresep.c,v 1.2 2007/12/06 22:07:07 seb Exp $");
+__RCSID("$NetBSD: stresep.c,v 1.3 2017/02/12 17:19:00 maya Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -76,7 +76,7 @@
        for (tok = s;;) {
                c = *s++;
                while (esc != '\0' && c == esc) {
-                       (void)strcpy(s - 1, s);
+                       memmove(s - 1, s, strlen(s));
                        c = *s++;
                }
                spanp = delim;



Home | Main Index | Thread Index | Old Index