Skip to content
Snippets Groups Projects
Commit fe154963 authored by swym's avatar swym
Browse files

card10.cfg: have strtol detect base, fix zero-termination bug for

strings
parent 58d60e81
Branches
No related tags found
No related merge requests found
Pipeline #3584 passed
......@@ -73,15 +73,7 @@ static bool set_int(struct config_option *opt, const char *value)
{
char *endptr;
size_t len = strlen(value);
int base = 10;
if (len > 2 && value[0] == '0' && value[1] == 'x') {
base = 16;
#ifdef CONFIG_ENABLE_OCTAL_NUMBERS
} else if (len > 1 && value[0] == '0') {
base = 8;
#endif
}
int v = strtol(value, &endptr, base);
int v = strtol(value, &endptr, 0);
if (endptr != (value + len)) {
return false;
}
......@@ -122,8 +114,9 @@ static bool set_string(struct config_option *opt, const char *value)
{
//this leaks, but the lifetime of these ends when epicardium exits, so...
size_t len = strlen(value);
char *leaks = (char *)malloc(len);
char *leaks = (char *)malloc(len + 1);
strncpy(leaks, value, len);
leaks[len] = '\0';
opt->value.string = leaks;
LOG_DEBUG("card10.cfg", "setting '%s' to %s", opt->name, elide(leaks));
return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment