From 52f02f0f8614afa7d4776e90d955eff9c3659f80 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Mon, 25 Nov 2013 02:03:43 +0100 Subject: [PATCH] sorted_winttogle_and_activate() now sufficiently tolerates toggle_order_and_activate files that go beyond there intended length. --- config/windows/toggle_order_and_active | 2 +- src/readwrite.h | 4 ++-- src/wincontrol.c | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/config/windows/toggle_order_and_active b/config/windows/toggle_order_and_active index f188d83..2ae7c2c 100644 --- a/config/windows/toggle_order_and_active +++ b/config/windows/toggle_order_and_active @@ -1,2 +1,2 @@ kmicl -m \ No newline at end of file +m diff --git a/src/readwrite.h b/src/readwrite.h index 01a6f38..6f7bce3 100644 --- a/src/readwrite.h +++ b/src/readwrite.h @@ -33,8 +33,8 @@ extern void try_fclose_unlink_rename(FILE * file, char * p1, char * p2, char * f); /* Wrapper: Call textfile_sizes() from function called "f" to get max line - * length of "file", exit via exit_err() with trouble_msg()-generated error - * message on failure. + * length (includes newline char) of "file", exit via exit_err() with + * exit_trouble() on failure. */ extern uint16_t get_linemax(FILE * file, char * f); diff --git a/src/wincontrol.c b/src/wincontrol.c index bbb4c5c..6fb9acb 100644 --- a/src/wincontrol.c +++ b/src/wincontrol.c @@ -391,7 +391,6 @@ extern void sorted_wintoggle_and_activate() char * path = "config/windows/toggle_order_and_active"; FILE * file = try_fopen(path, "r", f_name); uint16_t linemax = get_linemax(file, f_name); - char win_order[linemax + 1]; try_fgets(win_order, linemax + 1, file, f_name); @@ -401,7 +400,7 @@ extern void sorted_wintoggle_and_activate() try_fclose(file, f_name); uint8_t i = 0; - for (; i < linemax - 1; i++) + for (; i < strlen(win_order) - 1; i++) { if (NULL == strchr(world.winconf_ids, win_order[i])) { -- 2.30.2