mirror of
https://github.com/open-simh/simtools.git
synced 2026-01-13 15:27:18 +00:00
Replace dodgy strncpy() with better range-checked variant.
This commit is contained in:
parent
90943eaf49
commit
2ac8b7eb5e
10
assemble.c
10
assemble.c
@ -616,8 +616,14 @@ static int assemble(
|
||||
macstr = new_buffer_stream(macbuf, label);
|
||||
buffer_free(macbuf);
|
||||
} else {
|
||||
strncpy(macfile, label, sizeof(macfile));
|
||||
strncat(macfile, ".MAC", sizeof(macfile) - strlen(macfile) - 1);
|
||||
char *bufend = &macfile[sizeof(macfile)],
|
||||
*end;
|
||||
end = stpncpy(macfile, label, sizeof(macfile) - 5);
|
||||
if (end >= bufend - 5) {
|
||||
report(stack->top, ".MCALL: name too long: '%s'\n", label);
|
||||
return 0;
|
||||
}
|
||||
stpncpy(end, ".MAC", bufend - end);
|
||||
my_searchenv(macfile, "MCALL", hitfile, sizeof(hitfile));
|
||||
if (hitfile[0])
|
||||
macstr = new_file_stream(hitfile);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user