=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/input-keys.c,v retrieving revision 1.89 retrieving revision 1.90 diff -c -r1.89 -r1.90 *** src/usr.bin/tmux/input-keys.c 2022/03/01 15:20:22 1.89 --- src/usr.bin/tmux/input-keys.c 2022/05/30 13:02:55 1.90 *************** *** 1,4 **** ! /* $OpenBSD: input-keys.c,v 1.89 2022/03/01 15:20:22 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: input-keys.c,v 1.90 2022/05/30 13:02:55 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 607,625 **** len = xsnprintf(buf, sizeof buf, "\033[<%u;%u;%u%c", m->sgr_b, x + 1, y + 1, m->sgr_type); } else if (s->mode & MODE_MOUSE_UTF8) { ! if (m->b > 0x7ff - 32 || x > 0x7ff - 33 || y > 0x7ff - 33) return (0); len = xsnprintf(buf, sizeof buf, "\033[M"); ! len += input_key_split2(m->b + 32, &buf[len]); ! len += input_key_split2(x + 33, &buf[len]); ! len += input_key_split2(y + 33, &buf[len]); } else { ! if (m->b > 223) return (0); len = xsnprintf(buf, sizeof buf, "\033[M"); ! buf[len++] = m->b + 32; ! buf[len++] = x + 33; ! buf[len++] = y + 33; } *rbuf = buf; --- 607,640 ---- len = xsnprintf(buf, sizeof buf, "\033[<%u;%u;%u%c", m->sgr_b, x + 1, y + 1, m->sgr_type); } else if (s->mode & MODE_MOUSE_UTF8) { ! if (m->b > MOUSE_PARAM_UTF8_MAX - MOUSE_PARAM_BTN_OFF || ! x > MOUSE_PARAM_UTF8_MAX - MOUSE_PARAM_POS_OFF || ! y > MOUSE_PARAM_UTF8_MAX - MOUSE_PARAM_POS_OFF) return (0); len = xsnprintf(buf, sizeof buf, "\033[M"); ! len += input_key_split2(m->b + MOUSE_PARAM_BTN_OFF, &buf[len]); ! len += input_key_split2(x + MOUSE_PARAM_POS_OFF, &buf[len]); ! len += input_key_split2(y + MOUSE_PARAM_POS_OFF, &buf[len]); } else { ! if (m->b + MOUSE_PARAM_BTN_OFF > MOUSE_PARAM_MAX) return (0); + len = xsnprintf(buf, sizeof buf, "\033[M"); ! buf[len++] = m->b + MOUSE_PARAM_BTN_OFF; ! ! /* ! * The incoming x and y may be out of the range which can be ! * supported by the "normal" mouse protocol. Clamp the ! * coordinates to the supported range. ! */ ! if (x + MOUSE_PARAM_POS_OFF > MOUSE_PARAM_MAX) ! buf[len++] = MOUSE_PARAM_MAX; ! else ! buf[len++] = x + MOUSE_PARAM_POS_OFF; ! if (y + MOUSE_PARAM_POS_OFF > MOUSE_PARAM_MAX) ! buf[len++] = MOUSE_PARAM_MAX; ! else ! buf[len++] = y + MOUSE_PARAM_POS_OFF; } *rbuf = buf;