From 1cc845b26ce986a50efbc11b9796ad7bab8af0ca Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Fri, 10 Mar 2017 09:18:48 -0800 Subject: [PATCH] TMXR: Fix various potential buffer overruns (COVERITY) --- sim_tmxr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sim_tmxr.c b/sim_tmxr.c index 3cce619f..67b35019 100644 --- a/sim_tmxr.c +++ b/sim_tmxr.c @@ -850,7 +850,7 @@ if (mp->port) /* copy port */ if (mp->logfiletmpl[0]) /* logfile info */ sprintf (growstring(&tptr, 7 + strlen (mp->logfiletmpl)), ",Log=%s", mp->logfiletmpl); while ((*tptr == ',') || (*tptr == ' ')) - memcpy (tptr, tptr+1, strlen(tptr+1)+1); + memmove (tptr, tptr+1, strlen(tptr+1)+1); for (i=0; ilines; ++i) { char *lptr; lp = mp->ldsc + i; @@ -863,7 +863,7 @@ for (i=0; ilines; ++i) { } if (mp->lines == 1) while ((*tptr == ',') || (*tptr == ' ')) - memcpy (tptr, tptr+1, strlen(tptr+1)+1); + memmove (tptr, tptr+1, strlen(tptr+1)+1); if (*tptr == '\0') { free (tptr); tptr = NULL; @@ -2509,14 +2509,14 @@ while (*tptr) { if (0 == MATCH_CMD (gbuf, "CONNECT")) { if ((NULL == cptr) || ('\0' == *cptr)) return sim_messagef (SCPE_2FARG, "Missing Connect Specifier\n"); - strcpy (destination, cptr); + strncpy (destination, cptr, sizeof(destination)-1); continue; } if (0 == MATCH_CMD (gbuf, "SPEED")) { if ((NULL == cptr) || ('\0' == *cptr) || (_tmln_speed_delta (cptr) < 0)) return sim_messagef (SCPE_ARG, "Invalid Speed Specifier: %s\n", (cptr ? cptr : "")); - strcpy (speed, cptr); + strncpy (speed, cptr, sizeof(speed)-1); continue; } cptr = get_glyph (gbuf, port, ';');