Replace strcpy() and strcat() with safer functions
This commit is contained in:
parent
b5946dea77
commit
b7b4269455
|
@ -283,7 +283,7 @@ static struct symbol *mk_symbol(char *str)
|
||||||
}
|
}
|
||||||
sym->type = sym->dlcache = NULL;
|
sym->type = sym->dlcache = NULL;
|
||||||
sym->hash = memhash32(str, len) ^ 0xAAAAAAAA;
|
sym->hash = memhash32(str, len) ^ 0xAAAAAAAA;
|
||||||
strcpy(&sym->name[0], str);
|
memcpy(&sym->name[0], str, len + 1);
|
||||||
return sym;
|
return sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
c/flmain.c
11
c/flmain.c
|
@ -1,6 +1,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -39,17 +40,19 @@ extern value_t fl_file(value_t *args, uint32_t nargs);
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char fname_buf[1024];
|
char fname_buf[1024];
|
||||||
|
const char *bootfile = "flisp.boot";
|
||||||
|
|
||||||
fl_init(512 * 1024);
|
fl_init(512 * 1024);
|
||||||
|
|
||||||
fname_buf[0] = '\0';
|
fname_buf[0] = '\0';
|
||||||
value_t str = symbol_value(symbol("*install-dir*"));
|
value_t str = symbol_value(symbol("*install-dir*"));
|
||||||
char *exedir = (str == UNBOUND ? NULL : cvalue_data(str));
|
char *exedir = (str == UNBOUND ? NULL : cvalue_data(str));
|
||||||
if (exedir != NULL) {
|
if (exedir == NULL) {
|
||||||
strcat(fname_buf, exedir);
|
snprintf(fname_buf, sizeof(fname_buf), "%s", bootfile);
|
||||||
strcat(fname_buf, PATHSEPSTRING);
|
} else {
|
||||||
|
snprintf(fname_buf, sizeof(fname_buf), "%s%s%s", exedir,
|
||||||
|
PATHSEPSTRING, bootfile);
|
||||||
}
|
}
|
||||||
strcat(fname_buf, "flisp.boot");
|
|
||||||
|
|
||||||
value_t args[2];
|
value_t args[2];
|
||||||
fl_gc_handle(&args[0]);
|
fl_gc_handle(&args[0]);
|
||||||
|
|
Loading…
Reference in New Issue