diff options
author | Daniel Friesel <derf@finalrewind.org> | 2018-12-23 20:48:40 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2018-12-23 20:48:40 +0100 |
commit | 5c0ab94b0cd1b944127448f4228690f122b702ef (patch) | |
tree | ad40b76612043cc59c9a8a28d500299757a15367 /src | |
parent | c2efc3491979a9fadcc32496c319ebefcb2a8301 (diff) |
options.c: Note that sscanf calls are safe
Diffstat (limited to 'src')
-rw-r--r-- | src/options.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/options.c b/src/options.c index 333c8c7..34e248e 100644 --- a/src/options.c +++ b/src/options.c @@ -131,6 +131,7 @@ static void feh_load_options_for_theme(char *theme) char *rcpath = NULL; char *oldrcpath = NULL; char *confbase = getenv("XDG_CONFIG_HOME"); + // s, s1 and s2 must always have identical size char s[1024], s1[1024], s2[1024]; int cont = 0; int bspos; @@ -167,11 +168,19 @@ static void feh_load_options_for_theme(char *theme) s2[0] = '\0'; if (cont) { + /* + * fgets ensures that s contains no more than 1023 characters + * (+ 1 null byte) + */ sscanf(s, " %[^\n]\n", (char *) &s2); if (!*s2) break; D(("Got continued options %s\n", s2)); } else { + /* + * fgets ensures that s contains no more than 1023 characters + * (+ 1 null byte) + */ sscanf(s, "%s %[^\n]\n", (char *) &s1, (char *) &s2); if (!(*s1) || (!*s2) || (*s1 == '\n') || (*s1 == '#')) { cont = 0; |