Module Name:    src
Committed By:   christos
Date:           Sun May 31 23:24:24 UTC 2020

Modified Files:
        src/lib/libedit: terminal.c tty.c

Log Message:
use strlcpy() instead of strncpy() for gcc happiness


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/lib/libedit/terminal.c
cvs rdiff -u -r1.68 -r1.69 src/lib/libedit/tty.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libedit/terminal.c
diff -u src/lib/libedit/terminal.c:1.41 src/lib/libedit/terminal.c:1.42
--- src/lib/libedit/terminal.c:1.41	Tue Nov 12 15:59:46 2019
+++ src/lib/libedit/terminal.c	Sun May 31 19:24:23 2020
@@ -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 @@ terminal_settc(EditLine *el, int argc __
 	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

Index: src/lib/libedit/tty.c
diff -u src/lib/libedit/tty.c:1.68 src/lib/libedit/tty.c:1.69
--- src/lib/libedit/tty.c:1.68	Sun Dec  2 11:58:13 2018
+++ src/lib/libedit/tty.c	Sun May 31 19:24:23 2020
@@ -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 @@ tty_stty(EditLine *el, int argc __attrib
 
 	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]) {

Reply via email to