[dev] [st] OSC-52 payload being truncated

From: Suraj N. Kurapati <sunaku_AT_riseup.net>
Date: Tue, 15 Aug 2017 01:05:47 -0700

Hello,

I'm using st master at 7f990328e4fec8dfaaad311cb8af2304b58c872e where
this OSC-52 payload is exceeding strescseq.buf's STR_BUF_SIZE length:

printf
'\033]52;;Rm9yIGRlYnVnZ2luZywgcnVubmluZyB0bXV4IHdpdGggLXYgb3IgLXZ2IHdpbGwgZ2VuZXJhdGUgc2VydmVyIGFuZCBjbGllbnQgbG9nCmZpbGVzIGluIHRoZSBjdXJyZW50IGRpcmVjdG9yeS4KCnRtdXggbWFpbGluZyBsaXN0cyBhcmUgYXZhaWxhYmxlLiBGb3IgZ2VuZXJhbCBkaXNjdXNzaW9uIGFuZCBidWcgcmVwb3J0czoKCiAgICAgICAgaHR0cHM6Ly9ncm91cHMuZ
29vZ2xlLmNvbS9mb3J1bS8jIWZvcnVtL3RtdXgtdXNlcnMKCkFuZCBmb3IgR2l0IGNvbW1pdCBlbWFpbHM6CgogICAgICAgIGh0dHBzOi8vZ3JvdXBzLmdvb2dsZS5jb20vZm9ydW0vIyFmb3J1bS90bXV4LWdpdAoKU3Vic2NyaWJlIGJ5IHNlbmRpbmcgYW4gZW1haWwgdG8gPHRtdXgtdXNlcnMrcw==\a'

This triggers the following conditional in st.c, starting at line 2393:

    if (strescseq.len+len >= sizeof(strescseq.buf)-1) {
        /*
         * Here is a bug in terminals. If the user never sends
         * some code to stop the str or esc command, then st
         * will stop responding. But this is better than
         * silently failing with unknown characters. At least
         * then users will report back.
         *
         * In the case users ever get fixed, here is the code:
         */
        /*
         * term.esc = 0;
         * strhandle();
         */
        return;
    }

Going one frame above in the backtrace, to ttyread() on line 832, the
OSC-52 payload's last base64 unit "cw==" is currently being processed.

What's the best way to fix this? Is lengthening `strescseq.buf` okay?

Thanks for your consideration.

P.S. You can also watch an ASCII screencast of this issue at:
     https://asciinema.org/a/XIIcBrnZksfZ2EIsMtJkJxLLa?t=17

Received on Tue Aug 15 2017 - 10:05:47 CEST

This archive was generated by hypermail 2.3.0 : Tue Aug 15 2017 - 10:12:46 CEST