Merge pull request #865 from martinetd/str_truncation

Fix gcc string truncation warnings
master
Drew DeVault 7 years ago committed by GitHub
commit 4dbf7f8b88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -202,7 +202,10 @@ struct example_config *parse_args(int argc, char *argv[]) {
char cwd[MAXPATHLEN];
if (getcwd(cwd, sizeof(cwd)) != NULL) {
char buf[MAXPATHLEN];
snprintf(buf, MAXPATHLEN, "%s/%s", cwd, "wlr-example.ini");
if (snprintf(buf, MAXPATHLEN, "%s/%s", cwd, "wlr-example.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");

@ -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;
}

@ -55,7 +55,7 @@ struct wlr_output {
struct wl_global *wl_global;
struct wl_list wl_resources;
char name[16];
char name[24];
char make[48];
char model[16];
char serial[16];

@ -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");

@ -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;
}

Loading…
Cancel
Save