Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libedit use strlcpy() instead of strncpy() for gcc happi...
details: https://anonhg.NetBSD.org/src/rev/f01ddd4fc0a4
branches: trunk
changeset: 933950:f01ddd4fc0a4
user: christos <christos%NetBSD.org@localhost>
date: Sun May 31 23:24:23 2020 +0000
description:
use strlcpy() instead of strncpy() for gcc happiness
diffstat:
lib/libedit/terminal.c | 10 ++++------
lib/libedit/tty.c | 7 +++----
2 files changed, 7 insertions(+), 10 deletions(-)
diffs (59 lines):
diff -r 12e110b5e86b -r f01ddd4fc0a4 lib/libedit/terminal.c
--- a/lib/libedit/terminal.c Sun May 31 23:24:20 2020 +0000
+++ b/lib/libedit/terminal.c Sun May 31 23:24:23 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: terminal.c,v 1.41 2019/11/12 20:59:46 christos Exp $ */
+/* $NetBSD: terminal.c,v 1.42 2020/05/31 23:24:23 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95";
#else
-__RCSID("$NetBSD: terminal.c,v 1.41 2019/11/12 20:59:46 christos Exp $");
+__RCSID("$NetBSD: terminal.c,v 1.42 2020/05/31 23:24:23 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -1319,10 +1319,8 @@
if (argv == NULL || argv[1] == NULL || argv[2] == NULL)
return -1;
- strncpy(what, ct_encode_string(argv[1], &el->el_scratch), sizeof(what));
- what[sizeof(what) - 1] = '\0';
- strncpy(how, ct_encode_string(argv[2], &el->el_scratch), sizeof(how));
- how[sizeof(how) - 1] = '\0';
+ strlcpy(what, ct_encode_string(argv[1], &el->el_scratch), sizeof(what));
+ strlcpy(how, ct_encode_string(argv[2], &el->el_scratch), sizeof(how));
/*
* Do the strings first
diff -r 12e110b5e86b -r f01ddd4fc0a4 lib/libedit/tty.c
--- a/lib/libedit/tty.c Sun May 31 23:24:20 2020 +0000
+++ b/lib/libedit/tty.c Sun May 31 23:24:23 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tty.c,v 1.68 2018/12/02 16:58:13 christos Exp $ */
+/* $NetBSD: tty.c,v 1.69 2020/05/31 23:24:23 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: tty.c,v 1.68 2018/12/02 16:58:13 christos Exp $");
+__RCSID("$NetBSD: tty.c,v 1.69 2020/05/31 23:24:23 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -1163,8 +1163,7 @@
if (argv == NULL)
return -1;
- strncpy(name, ct_encode_string(*argv++, &el->el_scratch), sizeof(name));
- name[sizeof(name) - 1] = '\0';
+ strlcpy(name, ct_encode_string(*argv++, &el->el_scratch), sizeof(name));
while (argv && *argv && argv[0][0] == '-' && argv[0][2] == '\0')
switch (argv[0][1]) {
Home |
Main Index |
Thread Index |
Old Index