diff options
Diffstat (limited to 'rootston')
-rw-r--r-- | rootston/config.c | 5 | ||||
-rw-r--r-- | rootston/ini.c | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/rootston/config.c b/rootston/config.c index 0883f6d4..67bf83e9 100644 --- a/rootston/config.c +++ b/rootston/config.c @@ -418,7 +418,10 @@ struct roots_config *roots_config_create_from_args(int argc, char *argv[]) { char cwd[MAXPATHLEN]; if (getcwd(cwd, sizeof(cwd)) != NULL) { char buf[MAXPATHLEN]; - snprintf(buf, MAXPATHLEN, "%s/%s", cwd, "rootston.ini"); + if (snprintf(buf, MAXPATHLEN, "%s/%s", cwd, "rootston.ini") >= MAXPATHLEN) { + wlr_log(L_ERROR, "config path too long"); + exit(1); + } config->config_path = strdup(buf); } else { wlr_log(L_ERROR, "could not get cwd"); diff --git a/rootston/ini.c b/rootston/ini.c index 56cc9ea6..f515dd38 100644 --- a/rootston/ini.c +++ b/rootston/ini.c @@ -64,7 +64,7 @@ static char* find_chars_or_comment(const char* s, const char* chars) /* Version of strncpy that ensures dest (size bytes) is null-terminated. */ static char* strncpy0(char* dest, const char* src, size_t size) { - strncpy(dest, src, size); + strncpy(dest, src, size-1); dest[size - 1] = '\0'; return dest; } |