1
0
mirror of https://github.com/prirun/p50em.git synced 2026-04-12 14:52:44 +00:00

Convert strcpy() calls to strncpy().

Raise the size of the symbol name variable.
This commit is contained in:
Dennis Boone
2020-04-11 12:51:44 -04:00
parent 345c4d7ecc
commit 527611669b
4 changed files with 10 additions and 10 deletions

View File

@@ -881,7 +881,7 @@ int devamlc (int class, int func, int device) {
endconnect:
if (allbusy) {
//warn("No free AMLC connection");
strcpy(buf,"\r\nAll available connections are in use.\r\n\n");
strncpy(buf,"\r\nAll available connections are in use.\r\n\n", 2047);
write(fd, buf, strlen(buf));
close(fd);
} else {

View File

@@ -961,7 +961,7 @@ int devpnc (int class, int func, int device) {
fprintf(stderr,"Line %d of ring.cfg ignored: IP address too long\n", linenum);
continue;
}
strcpy(temphost, p);
strncpy(temphost, p, MAXHOSTLEN);
if ((p=strtok(NULL, DELIM)) == NULL) {
fprintf(stderr,"Line %d of ring.cfg ignored: unique id/password missing\n", linenum);
@@ -979,14 +979,14 @@ int devpnc (int class, int func, int device) {
}
if (i <= MAXNODEID)
continue;
strcpy(ni[tempid].uid, p);
strncpy(ni[tempid].uid, p, MAXUIDLEN);
/* parse the port number from the IP address */
tempport = 0;
if (strcmp(temphost, "-") != 0) {
if ((p=strtok(temphost, PDELIM)) != NULL) {
strcpy(ni[tempid].host, p);
strncpy(ni[tempid].host, p, MAXHOSTLEN);
if ((p=strtok(NULL, PDELIM)) != NULL) {
tempport = atoi(p);
if (tempport < 1 || tempport > 65000)

6
em.c
View File

@@ -667,10 +667,10 @@ static in_addr_t bindaddr = INADDR_ANY; /* -naddr option (PnC/Ringnet) */
/* load map related data, specified with -map */
#define MAXSYMBOLS 15000
#define MAXSYMLEN 9
#define MAXSYMLEN 11
static int numsyms = 0;
static struct {
char symname[MAXSYMLEN];
char symname[MAXSYMLEN+1];
ea_t address;
char symtype; /* o=other, c=common, e=ecb, p=proc, l=linkbase */
} mapsym[MAXSYMBOLS];
@@ -762,7 +762,7 @@ void addsym(char *sym, unsigned short seg, unsigned short word, char type) {
for (ix2 = numsyms; ix2 > ix; ix2--)
mapsym[ix2] = mapsym[ix2-1];
//TRACEA("%s = %o/%o\n", sym, seg, words);
strcpy(mapsym[ix+1].symname, sym);
strncpy(mapsym[ix+1].symname, sym, MAXSYMLEN);
mapsym[ix+1].address = addr;
mapsym[ix+1].symtype = type;
numsyms++;

View File

@@ -1913,11 +1913,11 @@ int devdisk (int class, int func, int device) {
head = m2 & 077;
u = dc[dx].usel;
if (order == 2)
strcpy(ordertext,"Format");
strncpy(ordertext,"Format", 7);
else if (order == 5)
strcpy(ordertext,"Read");
strncpy(ordertext,"Read", 7);
else if (order == 6)
strcpy(ordertext,"Write");
strncpy(ordertext,"Write", 7);
TRACE(T_INST|T_DIO, "%s, head=%d, track=%d, rec=%d, recsize=%d\n", ordertext, head, track, rec, recsize);
if (u == -1) {
fprintf(stderr," Device '%o, order %d with no unit selected\n", device, order);