SCP: Always invoke strlcpy, strlcat, strcasecmp and strcasencmp vs sim_ forms
This commit is contained in:
parent
f5a1048101
commit
2c6c8f4ef8
5 changed files with 36 additions and 36 deletions
|
@ -824,43 +824,43 @@ static void debug_fdccmd(uint16 cmd) {
|
||||||
|
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
if (cmd & 0xff00) {
|
if (cmd & 0xff00) {
|
||||||
sim_strlcat(buf,"DSR=[",sizeof(buf));
|
strlcat(buf,"DSR=[",sizeof(buf));
|
||||||
sim_strlcat(buf,dsel & FDC_SEL_SIDE ? "SIDE1" : "SIDE0",sizeof(buf));
|
strlcat(buf,dsel & FDC_SEL_SIDE ? "SIDE1" : "SIDE0",sizeof(buf));
|
||||||
if (dsel & FDC_SEL_SDEN) sim_strlcat(buf,",SDEN",sizeof(buf));
|
if (dsel & FDC_SEL_SDEN) strlcat(buf,",SDEN",sizeof(buf));
|
||||||
sim_strlcat(buf,",UNIT",sizeof(buf));
|
strlcat(buf,",UNIT",sizeof(buf));
|
||||||
if (dsel & FDC_SEL_UNIT3) sim_strlcat(buf,"3",sizeof(buf));
|
if (dsel & FDC_SEL_UNIT3) strlcat(buf,"3",sizeof(buf));
|
||||||
else if (dsel & FDC_SEL_UNIT2) sim_strlcat(buf,"2",sizeof(buf));
|
else if (dsel & FDC_SEL_UNIT2) strlcat(buf,"2",sizeof(buf));
|
||||||
else if (dsel & FDC_SEL_UNIT1) sim_strlcat(buf,"1",sizeof(buf));
|
else if (dsel & FDC_SEL_UNIT1) strlcat(buf,"1",sizeof(buf));
|
||||||
else if (dsel & FDC_SEL_UNIT0) sim_strlcat(buf,"0",sizeof(buf));
|
else if (dsel & FDC_SEL_UNIT0) strlcat(buf,"0",sizeof(buf));
|
||||||
sim_strlcat(buf,"] ",sizeof(buf));
|
strlcat(buf,"] ",sizeof(buf));
|
||||||
}
|
}
|
||||||
sim_strlcat(buf,"CR=[",sizeof(buf));
|
strlcat(buf,"CR=[",sizeof(buf));
|
||||||
sim_strlcat(buf,cmdlist[cr],sizeof(buf));
|
strlcat(buf,cmdlist[cr],sizeof(buf));
|
||||||
if (cr < 8) {
|
if (cr < 8) {
|
||||||
if (cmd & FDC_BIT_HEADLOAD) sim_strlcat(buf,"+Load",sizeof(buf));
|
if (cmd & FDC_BIT_HEADLOAD) strlcat(buf,"+Load",sizeof(buf));
|
||||||
if (cmd & FDC_BIT_VERIFY) sim_strlcat(buf,"+Vrfy",sizeof(buf));
|
if (cmd & FDC_BIT_VERIFY) strlcat(buf,"+Vrfy",sizeof(buf));
|
||||||
cmd &= FDC_BIT_STEP15;
|
cmd &= FDC_BIT_STEP15;
|
||||||
if (cmd == FDC_BIT_STEP3) sim_strlcat(buf,"+Step3",sizeof(buf));
|
if (cmd == FDC_BIT_STEP3) strlcat(buf,"+Step3",sizeof(buf));
|
||||||
else if (cmd == FDC_BIT_STEP6) sim_strlcat(buf,"+Step6",sizeof(buf));
|
else if (cmd == FDC_BIT_STEP6) strlcat(buf,"+Step6",sizeof(buf));
|
||||||
else if (cmd == FDC_BIT_STEP10) sim_strlcat(buf,"+Step10",sizeof(buf));
|
else if (cmd == FDC_BIT_STEP10) strlcat(buf,"+Step10",sizeof(buf));
|
||||||
else if (cmd == FDC_BIT_STEP15) sim_strlcat(buf,"+Step15",sizeof(buf));
|
else if (cmd == FDC_BIT_STEP15) strlcat(buf,"+Step15",sizeof(buf));
|
||||||
} else
|
} else
|
||||||
switch (cr) {
|
switch (cr) {
|
||||||
case 8: case 9:
|
case 8: case 9:
|
||||||
case 0xa: case 0xb:
|
case 0xa: case 0xb:
|
||||||
sim_strlcat(buf, cmd & FDC_BIT_SIDESEL ? "+SideSel1" : "+SideSel0",sizeof(buf));
|
strlcat(buf, cmd & FDC_BIT_SIDESEL ? "+SideSel1" : "+SideSel0",sizeof(buf));
|
||||||
sim_strlcat(buf, cmd & FDC_BIT_SIDECMP ? "+SideCmp1" : "+SideCmp0",sizeof(buf));
|
strlcat(buf, cmd & FDC_BIT_SIDECMP ? "+SideCmp1" : "+SideCmp0",sizeof(buf));
|
||||||
if (cr > 9)
|
if (cr > 9)
|
||||||
sim_strlcat(buf, cmd & FDC_BIT_DATAMARK ? "+DelMark" : "+DataMark",sizeof(buf));
|
strlcat(buf, cmd & FDC_BIT_DATAMARK ? "+DelMark" : "+DataMark",sizeof(buf));
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
case 0x0f:
|
case 0x0f:
|
||||||
if (cmd & FDC_BIT_INTIMM) sim_strlcat(buf,"+IMM",sizeof(buf));
|
if (cmd & FDC_BIT_INTIMM) strlcat(buf,"+IMM",sizeof(buf));
|
||||||
if (cmd & FDC_BIT_INTIDX) sim_strlcat(buf,"+IDX",sizeof(buf));
|
if (cmd & FDC_BIT_INTIDX) strlcat(buf,"+IDX",sizeof(buf));
|
||||||
if (cmd & FDC_BIT_INTN2R) sim_strlcat(buf,"+N2R",sizeof(buf));
|
if (cmd & FDC_BIT_INTN2R) strlcat(buf,"+N2R",sizeof(buf));
|
||||||
if (cmd & FDC_BIT_INTR2N) sim_strlcat(buf,"+R2N",sizeof(buf));
|
if (cmd & FDC_BIT_INTR2N) strlcat(buf,"+R2N",sizeof(buf));
|
||||||
}
|
}
|
||||||
sim_strlcat(buf,"]",sizeof(buf));
|
strlcat(buf,"]",sizeof(buf));
|
||||||
sim_debug(DBG_FD_CMD, &fdc_dev, DBG_PCFORMAT2 "Command: %s\n", DBG_PC,buf);
|
sim_debug(DBG_FD_CMD, &fdc_dev, DBG_PCFORMAT2 "Command: %s\n", DBG_PC,buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
scp.c
10
scp.c
|
@ -2046,7 +2046,7 @@ for (i = 1; i < argc; i++) { /* loop thru args */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (*cbuf) /* concat args */
|
if (*cbuf) /* concat args */
|
||||||
sim_strlcat (cbuf, " ", sizeof(cbuf));
|
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 */
|
||||||
}
|
}
|
||||||
|
@ -2957,7 +2957,7 @@ if (flag >= 0) { /* Only bump nesting fro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sim_strlcpy( sim_do_filename[sim_do_depth], do_arg[0],
|
strlcpy( sim_do_filename[sim_do_depth], do_arg[0],
|
||||||
sizeof (sim_do_filename[sim_do_depth])); /* stash away do file name for possible use by 'call' command */
|
sizeof (sim_do_filename[sim_do_depth])); /* stash away do file name for possible use by 'call' command */
|
||||||
sim_do_label[sim_do_depth] = label; /* stash away do label for possible use in messages */
|
sim_do_label[sim_do_depth] = label; /* stash away do label for possible use in messages */
|
||||||
sim_goto_line[sim_do_depth] = 0;
|
sim_goto_line[sim_do_depth] = 0;
|
||||||
|
@ -5130,7 +5130,7 @@ char DirName[PATH_MAX + 1], WholeName[PATH_MAX + 1], WildName[PATH_MAX + 1];
|
||||||
|
|
||||||
memset (DirName, 0, sizeof(DirName));
|
memset (DirName, 0, sizeof(DirName));
|
||||||
memset (WholeName, 0, sizeof(WholeName));
|
memset (WholeName, 0, sizeof(WholeName));
|
||||||
sim_strlcpy (WildName, cptr, sizeof(WildName));
|
strlcpy (WildName, cptr, sizeof(WildName));
|
||||||
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))
|
||||||
|
@ -5146,7 +5146,7 @@ if ((*cptr != '/') || (0 == memcmp (cptr, "./", 2)) || (0 == memcmp (cptr, "../"
|
||||||
sim_trim_endspc (WholeName);
|
sim_trim_endspc (WholeName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sim_strlcpy (WholeName, cptr, sizeof(WholeName));
|
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, "//")))
|
||||||
|
@ -5410,7 +5410,7 @@ char FullPath[PATH_MAX + 1];
|
||||||
char dname[CBUFSIZE];\
|
char dname[CBUFSIZE];\
|
||||||
t_stat st;
|
t_stat st;
|
||||||
|
|
||||||
sim_strlcpy (dname, ctx->destname, sizeof (dname));
|
strlcpy (dname, ctx->destname, sizeof (dname));
|
||||||
|
|
||||||
sprintf (FullPath, "%s%s", directory, filename);
|
sprintf (FullPath, "%s%s", directory, filename);
|
||||||
|
|
||||||
|
|
|
@ -409,7 +409,7 @@ typedef uint32 t_addr;
|
||||||
|
|
||||||
/* String match - at least one character required */
|
/* String match - at least one character required */
|
||||||
|
|
||||||
#define MATCH_CMD(ptr,cmd) ((NULL == (ptr)) || (!*(ptr)) || sim_strncasecmp ((ptr), (cmd), strlen (ptr)))
|
#define MATCH_CMD(ptr,cmd) ((NULL == (ptr)) || (!*(ptr)) || strncasecmp ((ptr), (cmd), strlen (ptr)))
|
||||||
|
|
||||||
/* End of Linked List/Queue value */
|
/* End of Linked List/Queue value */
|
||||||
/* Chosen for 2 reasons: */
|
/* Chosen for 2 reasons: */
|
||||||
|
|
|
@ -711,7 +711,7 @@ char* eth_getname_byname(const char* name, char* temp, char *desc)
|
||||||
n = strlen(name);
|
n = strlen(name);
|
||||||
for (i=0; i<count && !found; i++) {
|
for (i=0; i<count && !found; i++) {
|
||||||
if ((n == strlen(list[i].name)) &&
|
if ((n == strlen(list[i].name)) &&
|
||||||
(sim_strncasecmp(name, list[i].name, n) == 0)) {
|
(strncasecmp(name, list[i].name, n) == 0)) {
|
||||||
found = 1;
|
found = 1;
|
||||||
strcpy(temp, list[i].name); /* only case might be different */
|
strcpy(temp, list[i].name); /* only case might be different */
|
||||||
strcpy(desc, list[i].desc);
|
strcpy(desc, list[i].desc);
|
||||||
|
@ -731,7 +731,7 @@ char* eth_getdesc_byname(char* name, char* temp)
|
||||||
n = strlen(name);
|
n = strlen(name);
|
||||||
for (i=0; i<count && !found; i++) {
|
for (i=0; i<count && !found; i++) {
|
||||||
if ((n == strlen(list[i].name)) &&
|
if ((n == strlen(list[i].name)) &&
|
||||||
(sim_strncasecmp(name, list[i].name, n) == 0)) {
|
(strncasecmp(name, list[i].name, n) == 0)) {
|
||||||
found = 1;
|
found = 1;
|
||||||
strcpy(temp, list[i].desc);
|
strcpy(temp, list[i].desc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -302,7 +302,7 @@ found = 0;
|
||||||
n = strlen(name);
|
n = strlen(name);
|
||||||
for (i=0; i<count && !found; i++) {
|
for (i=0; i<count && !found; i++) {
|
||||||
if ((n == strlen(list[i].name)) &&
|
if ((n == strlen(list[i].name)) &&
|
||||||
(sim_strncasecmp(name, list[i].name, n) == 0)) {
|
(strncasecmp(name, list[i].name, n) == 0)) {
|
||||||
found = 1;
|
found = 1;
|
||||||
strcpy(temp, list[i].name); /* only case might be different */
|
strcpy(temp, list[i].name); /* only case might be different */
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ found = 0;
|
||||||
n = strlen(name);
|
n = strlen(name);
|
||||||
for (i=0; i<count && !found; i++) {
|
for (i=0; i<count && !found; i++) {
|
||||||
if ((n == strlen(list[i].name)) &&
|
if ((n == strlen(list[i].name)) &&
|
||||||
(sim_strncasecmp(name, list[i].name, n) == 0)) {
|
(strncasecmp(name, list[i].name, n) == 0)) {
|
||||||
found = 1;
|
found = 1;
|
||||||
strcpy(temp, list[i].desc);
|
strcpy(temp, list[i].desc);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue