scandum / tintin

TinTin++, aka tt++, is an extensible console MUD client.
https://tintin.mudhalla.net
GNU General Public License v3.0
201 stars 56 forks source link

`\x00` cannot be sent via the `#send` command when `#config charset GBK1TOUTF8` #194

Closed dzpao closed 10 months ago

dzpao commented 1 year ago

\x00 cannot be sent via the #send command when #config charset GBK1TOUTF8. If the charset is UTF-8, there is no problem.

dzpao commented 1 year ago

It could be caused by this code in net.c

    if (!HAS_BIT(ses->telopts, TELOPT_FLAG_TELNET) && HAS_BIT(ses->charset, CHARSET_FLAG_ALL_TOUTF8))
    {
        char buf[BUFFER_SIZE];

        size = utf8_to_all(ses, line, buf); <------ HERE

        memcpy(line, buf, size);

        line[size] = 0;
    }
dzpao commented 1 year ago

Because I want to send some IAC sub-negotiations via #send, some of these codes may be \x00.

scandum commented 1 year ago

Thanks, the problem is indeed with that specific code, which passes line as a string, instead of as data.

I updated the beta version with a fix for gb1ktoutf8, would you mind testing it?

dzpao commented 1 year ago

Sure, I'll take a look right away.

dzpao commented 1 year ago

Tested it, now that's no problem.