mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
Fix gcc string truncation warnings
This commit is contained in:
parent
99b92b4104
commit
555206cf60
5 changed files with 11 additions and 5 deletions
|
@ -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…
Reference in a new issue