-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stty.c wrongly parse first argument as c_iflags #251
Comments
i'm not certain exactly what you're trying to report (it's always helpful to include "what i did", "what i expected to see", and "what i actually saw" in a bug report), but i think you're talking about the bug fixed by 9c72f31 ? |
@enh-google Actually I think they're talking about a different bug, that was worsened by that commit (because the sscanf happens earlier), because sscanf would modify |
ah, right, so the example was meant to be yeah, that's broken as they describe (with
this patch (which i'll send to the list momentarily) corresponds to your suggestion:
and works for me:
|
Looks good |
First of all, I would apologize for the badly written bug report. This is my first bug report. |
cool, thanks for confirming that the suggested fix solves your problem! |
I look forward to someday getting a chance to clean up the rest of the stuff in pending, but between work and toysh my brain's been full enough it's taken multiple attempts to switch dirtree_path() to a non-recursive implementation. :P |
Fixes landley#251 where `stty 300` was mangling c_iflags to 0x300 because even if we don't match a full hex specification of struct termios, sscanf() will have overwritten the first value, which is c_iflag.
On Android 9, if I type
stty -F /dev/ttyS0 -echo
the new.c_iflag would become 0xffffff14
then I type
stty -F /dev/ttyS0
the new.c_iflag became normal as it should be.
after digging a while with my colleague
he found that in stty_main(),
else if (sscanf(arg, "%x:%x:%x:%x:%n", &new.c_iflag, &new.c_oflag,
&new.c_cflag, &new.c_lflag, &n) == 4)
should be responsible for this behavior.
no matter what argument is entered, new_c_iflag will be changed if the first letters in the argument is hexadecimal characters and/or the negative sign.
i understand this line of code is for convenience but it would break the functionality of stty.
The text was updated successfully, but these errors were encountered: