window(1): Add some format safety.
authorzrj <rimvydas.jasinskas@gmail.com>
Tue, 30 Jan 2018 19:50:13 +0000 (21:50 +0200)
committerzrj <zrj@dragonflybsd.org>
Fri, 2 Feb 2018 11:58:04 +0000 (13:58 +0200)
While there, add some FALLTHROUGH too.

usr.bin/window/cmd.c
usr.bin/window/parser1.c
usr.bin/window/parser3.c
usr.bin/window/scanner.c
usr.bin/window/ttzapple.c
usr.bin/window/wwenviron.c

index 020a792..2a1eb5f 100644 (file)
@@ -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) {
index f5733b9..60eaba4 100644 (file)
@@ -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;
index 313e6a2..1cd3008 100644 (file)
@@ -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;
index 38ca877..2bea9f6 100644 (file)
@@ -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;
index 9f20fe6..831ca0a 100644 (file)
@@ -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;
index a963944..410b274 100644 (file)
@@ -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);