I was going to bump the limit to 1K but that still seems a little short, try 
this please:

diff --git a/input.c b/input.c
index ee46c98..a8be6ad 100644
--- a/input.c
+++ b/input.c
@@ -701,6 +701,12 @@ input_init(struct window_pane *wp)
        *ictx->param_buf = '\0';
        ictx->param_len = 0;
 
+       ictx->input_space = 32;
+       ictx->input_buf = xmalloc(ictx->input_space);
+
+       *ictx->input_buf = '\0';
+       ictx->input_len = 0;
+
        ictx->state = &input_state_ground;
        ictx->flags = 0;
 
@@ -711,8 +717,11 @@ input_init(struct window_pane *wp)
 void
 input_free(struct window_pane *wp)
 {
-       if (wp != NULL)
-               evbuffer_free(wp->ictx.since_ground);
+       if (wp == NULL)
+               return;
+
+       free(wp->ictx.input_buf);
+       evbuffer_free(wp->ictx.since_ground);
 }
 
 /* Change input state. */
@@ -924,12 +933,20 @@ input_parameter(struct input_ctx *ictx)
 int
 input_input(struct input_ctx *ictx)
 {
-       if (ictx->input_len == (sizeof ictx->input_buf) - 1)
-               ictx->flags |= INPUT_DISCARD;
-       else {
-               ictx->input_buf[ictx->input_len++] = ictx->ch;
-               ictx->input_buf[ictx->input_len] = '\0';
+       size_t available;
+
+       available = ictx->input_space;
+       while (ictx->input_len + 1 >= available) {
+               available *= 2;
+               if (available > INPUT_LIMIT) {
+                       ictx->flags |= INPUT_DISCARD;
+                       return (0);
+               }
+               ictx->input_buf = xrealloc(ictx->input_buf, 1, available);
+               ictx->input_space = available;
        }
+       ictx->input_buf[ictx->input_len++] = ictx->ch;
+       ictx->input_buf[ictx->input_len] = '\0';
 
        return (0);
 }
@@ -1666,8 +1683,8 @@ input_enter_osc(struct input_ctx *ictx)
 void
 input_exit_osc(struct input_ctx *ictx)
 {
-       u_char *p = ictx->input_buf;
-       int     option;
+       u_char  *p = ictx->input_buf;
+       int              option;
 
        if (ictx->flags & INPUT_DISCARD)
                return;
diff --git a/tmux.h b/tmux.h
index dacda66..da5a18c 100644
--- a/tmux.h
+++ b/tmux.h
@@ -815,8 +815,9 @@ struct input_ctx {
        u_char                  param_buf[64];
        size_t                  param_len;
 
-       u_char                  input_buf[256];
+       u_char*                 input_buf;
        size_t                  input_len;
+       size_t                  input_space;
 
        int                     param_list[24]; /* -1 not present */
        u_int                   param_list_len;
@@ -835,6 +836,7 @@ struct input_ctx {
         */
        struct evbuffer         *since_ground;
 };
+#define INPUT_LIMIT 32768
 
 /*
  * Window mode. Windows can be in several modes and this is used to call the



On Mon, Apr 14, 2014 at 07:00:06PM -0700, Suraj Kurapati wrote:
> Hello,
> 
> I found a simpler way to reproduce this issue.  For instance, this works:
> 
> bash$ printf '\ePtmux;\e\e]52;c;%s\a\e\\' "$(cat README | head -c180 |
> base64 -w0)"
> 
> But if you specify a number larger than 180 to `head -c`, the copy fails:
> 
> bash$ printf '\ePtmux;\e\e]52;c;%s\a\e\\' "$(cat README | head -c181 |
> base64 -w0)"
> 
> What is the recommended way to copy more than 180 bytes via OSC52 in tmux?
> 
> Thanks for your consideration.
> 
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/NeoTech
> _______________________________________________
> tmux-users mailing list
> tmux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tmux-users

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to