Shadytel / shadysoftmodem

3 stars 1 forks source link

8bit safety #1

Open Manawyrm opened 2 years ago

Manawyrm commented 2 years ago

It looks like shadysoftmodem is misinterpreting 8bit data as UTF-8 and trying to parse it as Unicode.

This only happens when the environment spawning yate (and thus shadysoftmodem) has LANG set to something with UTF-8 (like de_DE.UTF-8). Setting it LANG=C makes 8bit data work fine.

I've tried to add set stty_init "-istrip -parenb cs8" to the .expect file and it didn't change anything, but I'm not very familiar with expect. Otherwise we could also just export LANG=C in the ssm scripts? :smile:

Thanks!

Manawyrm commented 2 years ago

... easy way to test this: Use HTerm or any other terminal that can display hex data, then run

#!/usr/bin/php
<?php
passthru("stty 2>&1");
passthru("export 2>&1");

echo "8bit Test: \r\n";

for ($i = 0; $i <= 255; $i++)
{
    echo chr($i);
}

flush();

as your script.

mercnz commented 2 months ago

I've just been setting LANG=C in a wrapper script that my yate config loads that calls the normal inbound_modem_attach which works around it for me. i think it's because it's using cout in the code. I do wonder how to work around better. I'm not sure why it's using cout, it should be doing it's own buffering?