From 30fb8e303b1c481c47cdfbf367cd2964496d7a00 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 17 Apr 2023 17:57:35 +0000 Subject: [PATCH] Discard mouse sequences that have the right form but actually are invalid (for example have column zero rather than one). --- usr.bin/tmux/tty-keys.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/usr.bin/tmux/tty-keys.c b/usr.bin/tmux/tty-keys.c index f5417b7e9d1..6d86f14b8ab 100644 --- a/usr.bin/tmux/tty-keys.c +++ b/usr.bin/tmux/tty-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty-keys.c,v 1.165 2023/01/09 14:12:41 nicm Exp $ */ +/* $OpenBSD: tty-keys.c,v 1.166 2023/04/17 17:57:35 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1008,7 +1008,8 @@ tty_keys_extended_key(struct tty *tty, const char *buf, size_t len, /* * Handle mouse key input. Returns 0 for success, -1 for failure, 1 for partial - * (probably a mouse sequence but need more data). + * (probably a mouse sequence but need more data), -2 if an invalid mouse + * sequence. */ static int tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size, @@ -1069,7 +1070,7 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size, if (b < MOUSE_PARAM_BTN_OFF || x < MOUSE_PARAM_POS_OFF || y < MOUSE_PARAM_POS_OFF) - return (-1); + return (-2); b -= MOUSE_PARAM_BTN_OFF; x -= MOUSE_PARAM_POS_OFF; y -= MOUSE_PARAM_POS_OFF; @@ -1111,7 +1112,7 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size, /* Check and return the mouse input. */ if (x < 1 || y < 1) - return (-1); + return (-2); x--; y--; b = sgr_b; -- 2.20.1