--- ChangeLog | 14 ++++++++++++++ telnet/commands.c | 6 +++--- 2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog index 96490b50..4fa4640b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2020-04-27 Tim Rühsen <[email protected]> + + telnet: Use memove for overlapping memory instead of strncpy. + + Overlapping source and destination buffers are not supported + by strncpy and give undefined results. + + 7.24.2.3 of ISO/IEC 9899:201x: + "If copying takes place between objects thatoverlap, + the behavior is undefined." + + * telnet/commands.c (cmds): Use memove for overlapping memory + instead of strncpy. + 2020-04-12 Mats Erik Andersson <[email protected]> whois: Delegation of IP and AS. diff --git a/telnet/commands.c b/telnet/commands.c index 29b2bfd4..ca3010bf 100644 --- a/telnet/commands.c +++ b/telnet/commands.c @@ -3108,11 +3108,11 @@ cmdrc (char *m1, char *m2) if (isspace (line[0])) continue; if (strncasecmp (line, m1, l1) == 0) - strncpy (line, &line[l1], sizeof (line) - l1); + memmove (line, &line[l1], strlen(&line[l1]) + 1); else if (strncasecmp (line, m2, l2) == 0) - strncpy (line, &line[l2], sizeof (line) - l2); + memmove (line, &line[l2], strlen(&line[l2]) + 1); else if (strncasecmp (line, "DEFAULT", 7) == 0) - strncpy (line, &line[7], sizeof (line) - 7); + memmove (line, &line[7], strlen(&line[7]) + 1); else continue; if (line[0] != ' ' && line[0] != '\t' && line[0] != '\n') -- 2.26.2
