summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/input.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2024-11-11 08:41:06 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2024-11-11 08:41:06 +0000
commit93907157e6f8e20f73a7372b9746fd062032d753 (patch)
tree2f976a5eb9916f1cb9e5223ade02c513247c7fc7 /usr.bin/tmux/input.c
parente871a2661d94d8f77e3e1f1517136bec197a4fe4 (diff)
Add an option to control the input buffer size, from Ken Lau.
Diffstat (limited to 'usr.bin/tmux/input.c')
-rw-r--r--usr.bin/tmux/input.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c
index f8755eec641..d78452ed1f1 100644
--- a/usr.bin/tmux/input.c
+++ b/usr.bin/tmux/input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: input.c,v 1.231 2024/10/25 15:00:18 nicm Exp $ */
+/* $OpenBSD: input.c,v 1.232 2024/11/11 08:41:05 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -93,7 +93,6 @@ struct input_ctx {
size_t param_len;
#define INPUT_BUF_START 32
-#define INPUT_BUF_LIMIT 1048576
u_char *input_buf;
size_t input_len;
size_t input_space;
@@ -729,6 +728,9 @@ static const struct input_transition input_state_consume_st_table[] = {
{ -1, -1, NULL, NULL }
};
+/* Maximum of bytes allowed to read in a single input. */
+static size_t input_buffer_size = INPUT_BUF_DEFAULT_SIZE;
+
/* Input table compare. */
static int
input_table_compare(const void *key, const void *value)
@@ -1193,7 +1195,7 @@ input_input(struct input_ctx *ictx)
available = ictx->input_space;
while (ictx->input_len + 1 >= available) {
available *= 2;
- if (available > INPUT_BUF_LIMIT) {
+ if (available > input_buffer_size) {
ictx->flags |= INPUT_DISCARD;
return (0);
}
@@ -3017,3 +3019,11 @@ input_reply_clipboard(struct bufferevent *bev, const char *buf, size_t len,
bufferevent_write(bev, end, strlen(end));
free(out);
}
+
+/* Set input buffer size. */
+void
+input_set_buffer_size(size_t buffer_size)
+{
+ log_debug("%s: %lu -> %lu", __func__, input_buffer_size, buffer_size);
+ input_buffer_size = buffer_size;
+}