SCP: Migrate some use of strcat() to sim_strlcat()

This commit is contained in:
Mark Pizzolato 2017-03-27 08:23:03 -07:00
parent ec11ecab87
commit f4b7d1fbf8
3 changed files with 10 additions and 10 deletions

14
scp.c
View file

@ -2027,7 +2027,7 @@ for (i = 1; i < argc; i++) { /* loop thru args */
return 0; return 0;
} }
if (*cbuf) /* concat args */ if (*cbuf) /* concat args */
strcat (cbuf, " "); sim_strlcat (cbuf, " ", sizeof(cbuf));
sprintf(&cbuf[strlen(cbuf)], "%s%s%s", strchr(argv[i], ' ') ? "\"" : "", argv[i], strchr(argv[i], ' ') ? "\"" : ""); sprintf(&cbuf[strlen(cbuf)], "%s%s%s", strchr(argv[i], ' ') ? "\"" : "", argv[i], strchr(argv[i], ' ') ? "\"" : "");
lookswitch = FALSE; /* no more switches */ lookswitch = FALSE; /* no more switches */
} }
@ -2113,7 +2113,7 @@ else if (*argv[0]) { /* sim name arg? */
strncpy (nbuf + 1, argv[0], PATH_MAX + 1); /* copy sim name */ strncpy (nbuf + 1, argv[0], PATH_MAX + 1); /* copy sim name */
if ((np = (char *)match_ext (nbuf, "EXE"))) /* remove .exe */ if ((np = (char *)match_ext (nbuf, "EXE"))) /* remove .exe */
*np = 0; *np = 0;
strcat (nbuf, ".ini\""); /* add .ini" */ sim_strlcat (nbuf, ".ini\"", sizeof(nbuf)); /* add .ini" */
stat = do_cmd (-1, nbuf) & ~SCPE_NOMESSAGE; /* proc default cmd file */ stat = do_cmd (-1, nbuf) & ~SCPE_NOMESSAGE; /* proc default cmd file */
if (stat == SCPE_OPENERR) { /* didn't exist/can't open? */ if (stat == SCPE_OPENERR) { /* didn't exist/can't open? */
np = strrchr (nbuf, '/'); /* stript path and try again in cwd */ np = strrchr (nbuf, '/'); /* stript path and try again in cwd */
@ -2906,7 +2906,7 @@ for (nargs = 0; nargs < 10; ) { /* extract arguments */
if (do_arg [0] == NULL) /* need at least 1 */ if (do_arg [0] == NULL) /* need at least 1 */
return SCPE_2FARG; return SCPE_2FARG;
if ((fpin = fopen (do_arg[0], "r")) == NULL) { /* file failed to open? */ if ((fpin = fopen (do_arg[0], "r")) == NULL) { /* file failed to open? */
strcat (strcpy (cbuf, do_arg[0]), ".sim"); /* try again with .sim extension */ sim_strlcat (strcpy (cbuf, do_arg[0]), ".sim", sizeof(cbuf));/* try again with .sim extension */
if ((fpin = fopen (cbuf, "r")) == NULL) { /* failed a second time? */ if ((fpin = fopen (cbuf, "r")) == NULL) { /* failed a second time? */
if (flag == 0) /* cmd line file? */ if (flag == 0) /* cmd line file? */
fprintf (stderr, "Can't open file %s\n", do_arg[0]); fprintf (stderr, "Can't open file %s\n", do_arg[0]);
@ -5076,19 +5076,19 @@ strcpy (WildName, cptr);
cptr = WildName; cptr = WildName;
sim_trim_endspc (WildName); sim_trim_endspc (WildName);
if ((!stat (WildName, &filestat)) && (filestat.st_mode & S_IFDIR)) if ((!stat (WildName, &filestat)) && (filestat.st_mode & S_IFDIR))
strcat (WildName, "/*"); sim_strlcat (WildName, "/*", sizeof(WildName));
if ((*cptr != '/') || (0 == memcmp (cptr, "./", 2)) || (0 == memcmp (cptr, "../", 3))) { if ((*cptr != '/') || (0 == memcmp (cptr, "./", 2)) || (0 == memcmp (cptr, "../", 3))) {
#if defined (VMS) #if defined (VMS)
getcwd (WholeName, PATH_MAX, 0); getcwd (WholeName, PATH_MAX, 0);
#else #else
getcwd (WholeName, PATH_MAX); getcwd (WholeName, PATH_MAX);
#endif #endif
strcat (WholeName, "/"); sim_strlcat (WholeName, "/", sizeof(WholeName));
strcat (WholeName, cptr); sim_strlcat (WholeName, cptr, sizeof(WholeName));
sim_trim_endspc (WholeName); sim_trim_endspc (WholeName);
} }
else else
strcpy (WholeName, cptr); sim_strlcpy (WholeName, cptr, sizeof(WholeName));
while ((c = strstr (WholeName, "/./"))) while ((c = strstr (WholeName, "/./")))
memmove (c + 1, c + 3, 1 + strlen (c + 3)); memmove (c + 1, c + 3, 1 + strlen (c + 3));
while ((c = strstr (WholeName, "//"))) while ((c = strstr (WholeName, "//")))

View file

@ -3598,8 +3598,8 @@ static t_stat sim_os_ttinit (void) {
SIOUXSettings.toppixel = 42; SIOUXSettings.toppixel = 42;
SIOUXSettings.leftpixel = 6; SIOUXSettings.leftpixel = 6;
iBeamCursorH = GetCursor(iBeamCursor); iBeamCursorH = GetCursor(iBeamCursor);
strcat(title, sim_name); sim_strlcat(title, sim_name, sizeof(title));
strcat(title, " Simulator"); sim_strlcat(title, " Simulator", sizeof(title));
title[0] = strlen(title) - 1; /* Pascal string done */ title[0] = strlen(title) - 1; /* Pascal string done */
for (i = 0; i <= title[0]; i++) { /* copy to unsigned char */ for (i = 0; i <= title[0]; i++) { /* copy to unsigned char */
ptitle[i] = title[i]; ptitle[i] = title[i];

View file

@ -1144,7 +1144,7 @@ int load_pcap(void) {
char npcap_path[512] = ""; char npcap_path[512] = "";
if (p_GetSystemDirectory (npcap_path, sizeof(npcap_path) - 7)) if (p_GetSystemDirectory (npcap_path, sizeof(npcap_path) - 7))
strcat (npcap_path, "\\Npcap"); sim_strlcat (npcap_path, "\\Npcap", sizeof(npcap_path));
if (p_SetDllDirectory(npcap_path)) if (p_SetDllDirectory(npcap_path))
hLib = LoadLibraryA(lib_name); hLib = LoadLibraryA(lib_name);
p_SetDllDirectory (NULL); p_SetDllDirectory (NULL);