summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/input.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2018-04-10 11:20:16 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2018-04-10 11:20:16 +0000
commit0096c94cebb8ff00bc4a5b63c325578692676206 (patch)
tree80ed255af43182de141c4dca247036db9c7de060 /usr.bin/tmux/input.c
parentf3325d003e8bfa6d01ddb0c69f7c9e683dab0746 (diff)
A couple of fixes to the : form of SGR. Apparently there is an extra
argument that nobody knew about, so skip that if it exists. Also there are a bunch of useless optional arguments at the end, so ignore those.
Diffstat (limited to 'usr.bin/tmux/input.c')
-rw-r--r--usr.bin/tmux/input.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c
index 1633848dbab..cfe2577d579 100644
--- a/usr.bin/tmux/input.c
+++ b/usr.bin/tmux/input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: input.c,v 1.133 2018/04/06 09:09:38 nicm Exp $ */
+/* $OpenBSD: input.c,v 1.134 2018/04/10 11:20:15 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1845,10 +1845,12 @@ input_csi_dispatch_sgr_colon(struct input_ctx *ictx, u_int i)
ptr = copy = xstrdup(s);
while ((out = strsep(&ptr, ":")) != NULL) {
- p[n++] = strtonum(out, 0, INT_MAX, &errstr);
- if (errstr != NULL || n == nitems(p)) {
- free(copy);
- return;
+ if (*out != '\0') {
+ p[n++] = strtonum(out, 0, INT_MAX, &errstr);
+ if (errstr != NULL || n == nitems(p)) {
+ free(copy);
+ return;
+ }
}
log_debug("%s: %u = %d", __func__, n - 1, p[n - 1]);
}
@@ -1856,16 +1858,21 @@ input_csi_dispatch_sgr_colon(struct input_ctx *ictx, u_int i)
if (n == 0 || (p[0] != 38 && p[0] != 48))
return;
- switch (p[1]) {
+ if (p[1] == -1)
+ i = 2;
+ else
+ i = 1;
+ switch (p[i]) {
case 2:
- if (n != 5)
+ if (n < i + 4)
break;
- input_csi_dispatch_sgr_rgb_do(ictx, p[0], p[2], p[3], p[4]);
+ input_csi_dispatch_sgr_rgb_do(ictx, p[0], p[i + 1], p[i + 2],
+ p[i + 3]);
break;
case 5:
- if (n != 3)
+ if (n < i + 2)
break;
- input_csi_dispatch_sgr_256_do(ictx, p[0], p[2]);
+ input_csi_dispatch_sgr_256_do(ictx, p[0], p[i + 1]);
break;
}
}