From: zrj Date: Tue, 30 Jan 2018 19:50:13 +0000 (+0200) Subject: window(1): Add some format safety. X-Git-Tag: v5.3.0~263 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/1ab5e7ebcad803de80a4a1f8e68992af39a866cd window(1): Add some format safety. While there, add some FALLTHROUGH too. --- diff --git a/usr.bin/window/cmd.c b/usr.bin/window/cmd.c index 020a792514..2a1eb5fbfc 100644 --- a/usr.bin/window/cmd.c +++ b/usr.bin/window/cmd.c @@ -64,6 +64,7 @@ docmd(void) default: if (c != escapec) break; + /* FALLTHROUGH */ case 'h': case 'j': case 'k': case 'l': case 'y': case 'p': case ctrl('y'): @@ -193,6 +194,7 @@ docmd(void) c_debug(); break; } + /* FALLTHROUGH */ default: if (c == escapec) { if (checkproc(selwin) >= 0) { diff --git a/usr.bin/window/parser1.c b/usr.bin/window/parser1.c index f5733b950f..60eaba4162 100644 --- a/usr.bin/window/parser1.c +++ b/usr.bin/window/parser1.c @@ -100,6 +100,7 @@ top: case V_STR: p_error("if: Numeric value required."); str_free(t.v_str); + /* FALLTHROUGH */ case V_ERR: flag = 0; break; diff --git a/usr.bin/window/parser3.c b/usr.bin/window/parser3.c index 313e6a2dc4..1cd30082f2 100644 --- a/usr.bin/window/parser3.c +++ b/usr.bin/window/parser3.c @@ -67,6 +67,7 @@ p_expr(struct value *v, char flag) switch (t.v_type) { case V_NUM: p_error("%d: Not a variable.", t.v_num); + /* FALLTHROUGH */ case V_ERR: t.v_str = 0; break; @@ -98,6 +99,7 @@ p_expr0(struct value *v, char flag) p_error("?: Numeric left operand required."); str_free(v->v_str); v->v_type = V_ERR; + /* FALLTHROUGH */ case V_ERR: flag = 0; break; @@ -136,6 +138,7 @@ p_expr1(struct value *v, char flag) p_error("||: Numeric operands required."); str_free(v->v_str); v->v_type = V_ERR; + /* FALLTHROUGH */ case V_ERR: flag = 0; break; @@ -169,6 +172,7 @@ p_expr2(struct value *v, char flag) p_error("&&: Numeric operands required."); str_free(v->v_str); v->v_type = V_ERR; + /* FALLTHROUGH */ case V_ERR: flag = 0; break; diff --git a/usr.bin/window/scanner.c b/usr.bin/window/scanner.c index 38ca877630..2bea9f6156 100644 --- a/usr.bin/window/scanner.c +++ b/usr.bin/window/scanner.c @@ -288,6 +288,7 @@ loop: break; default: (void) s_ungetc(c); + /* FALLTHROUGH */ case EOF: *p = 0; cx.x_token = T_STR; @@ -335,6 +336,7 @@ loop: switch (c) { case '\n': (void) s_ungetc(c); + /* FALLTHROUGH */ case EOF: case '"': state = 2; @@ -359,6 +361,7 @@ loop: switch (c) { case '\n': (void) s_ungetc(c); + /* FALLTHROUGH */ case EOF: case '\'': state = 2; diff --git a/usr.bin/window/ttzapple.c b/usr.bin/window/ttzapple.c index 9f20fe69d6..831ca0ab56 100644 --- a/usr.bin/window/ttzapple.c +++ b/usr.bin/window/ttzapple.c @@ -158,11 +158,13 @@ same_row: switch (x) { case 2: ttctrl('f'); + /* FALLTHROUGH */ case 1: ttctrl('f'); goto out; case -2: ttctrl('h'); + /* FALLTHROUGH */ case -1: ttctrl('h'); goto out; @@ -181,11 +183,13 @@ same_row: switch (row - tt.tt_row) { case 2: ttctrl('j'); + /* FALLTHROUGH */ case 1: ttctrl('j'); goto out; case -2: ttctrl('k'); + /* FALLTHROUGH */ case -1: ttctrl('k'); goto out; diff --git a/usr.bin/window/wwenviron.c b/usr.bin/window/wwenviron.c index a963944b29..410b274867 100644 --- a/usr.bin/window/wwenviron.c +++ b/usr.bin/window/wwenviron.c @@ -92,7 +92,7 @@ wwenviron(struct ww *wp) * 1. setenv() copies the string, * 2. we've already called tgetent which copies the termcap entry. */ - (void) sprintf(buf, "%sco#%d:li#%d:%s", + (void) sprintf(buf, "%sco#%d:li#%d:%.800s", WWT_TERMCAP, wp->ww_w.nc, wp->ww_w.nr, wwwintermcap); (void) setenv("TERMCAP", buf, 1); (void) sprintf(buf, "%d", wp->ww_id + 1);