Remove all sprintf calls

Replace them with snprintf, which ensures buffer overflows won't
happen.
This commit is contained in:
Simon Ser 2022-02-08 09:52:24 +01:00 committed by Simon Zeni
parent ac7892371c
commit f707f583e1
4 changed files with 7 additions and 6 deletions

View file

@ -414,8 +414,8 @@ int swaynag_load_config(char *path, struct swaynag *swaynag, list_t *types) {
}
free(name);
} else {
char *flag = malloc(sizeof(char) * (nread + 3));
sprintf(flag, "--%s", line);
char *flag = malloc(nread + 3);
snprintf(flag, nread + 3, "--%s", line);
char *argv[] = {"swaynag", flag};
result = swaynag_parse_options(2, argv, swaynag, types, type,
NULL, NULL);