Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/telnet use memmove() instead of strncpy() for overla...
details: https://anonhg.NetBSD.org/src/rev/977d38e859d3
branches: trunk
changeset: 1003900:977d38e859d3
user: mrg <mrg%NetBSD.org@localhost>
date: Fri Oct 04 11:39:44 2019 +0000
description:
use memmove() instead of strncpy() for overlapping strings.
ensure nul termination.
diffstat:
usr.bin/telnet/commands.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diffs (36 lines):
diff -r 2ad701a76353 -r 977d38e859d3 usr.bin/telnet/commands.c
--- a/usr.bin/telnet/commands.c Fri Oct 04 11:12:16 2019 +0000
+++ b/usr.bin/telnet/commands.c Fri Oct 04 11:39:44 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: commands.c,v 1.76 2019/01/05 08:55:58 maya Exp $ */
+/* $NetBSD: commands.c,v 1.77 2019/10/04 11:39:44 mrg Exp $ */
/*
* Copyright (C) 1997 and 1998 WIDE Project.
@@ -63,7 +63,7 @@
#if 0
static char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95";
#else
-__RCSID("$NetBSD: commands.c,v 1.76 2019/01/05 08:55:58 maya Exp $");
+__RCSID("$NetBSD: commands.c,v 1.77 2019/10/04 11:39:44 mrg Exp $");
#endif
#endif /* not lint */
@@ -2503,13 +2503,14 @@
if (isspace((unsigned char)line[0]))
continue;
if (strncasecmp(line, m1, l1) == 0)
- strncpy(line, &line[l1], sizeof(line) - l1);
+ memmove(line, &line[l1], sizeof(line) - l1 - 1);
else if (strncasecmp(line, m2, l2) == 0)
- strncpy(line, &line[l2], sizeof(line) - l2);
+ memmove(line, &line[l2], sizeof(line) - l2 - 1);
else if (strncasecmp(line, "DEFAULT", 7) == 0)
- strncpy(line, &line[7], sizeof(line) - 7);
+ memmove(line, &line[7], sizeof(line) - 7 - 1);
else
continue;
+ line[sizeof(line) - 1] = '\0';
if (line[0] != ' ' && line[0] != '\t' && line[0] != '\n')
continue;
gotmachine = 1;
Home |
Main Index |
Thread Index |
Old Index