Skip to content
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

Bug: scanf class of functions doesn't support conversion specifier [ #1301

Open
kedorlaomer opened this issue Sep 23, 2024 · 0 comments
Open
Labels
medium severity Used to report medium severity bugs (e.g. Malfunctioning Features but still useable)

Comments

@kedorlaomer
Copy link

Contact Details

adler@openhardware.de

What happened?

Thumbs up for the lovely cosmopolitan libc, I'm using it almost daily!

I was trying to compile openssh-client (9.9, but I tried an older one, too). With a few minor tweaks of the source code, the compilation succeeds. The resulting binary, however, claims to be unable to parse the remote's version string and yields errors such as:

Bad remote protocol version identification: 'SSH-2.0-OpenSSH_9.9'
banner exchange: Connection to 1.2.3.4 port 22: invalid format

The reasons is that in the function kex_exchange_identification in kex.c of openssh, the function sscanf is used with a conversion specifier [ to parse the version string:

 if (sscanf(peer_version_string, "SSH-%d.%d-%[^\n]",
            &remote_major, &remote_minor, remote_version) != 3) {
                error("Bad remote protocol version identification: '%.100s'",
                    peer_version_string);
 invalid:
                send_error(ssh, "Invalid SSH identification string.");

This use of sscanf is mandated in POSIX, so we should also have it.

Before I start warming up my C compiler and preparing a merge request: Do we want this functionality in cosmopolitan libc? Is it somewhere on the roadmap already? Should I indeed try to implement it myself? I estimate it's two or three dozens lines, but I'm not quite sure which infrastructure exists in libc/stdio/vcscanf.c since I haven't studied it properly yet.

Version

cosmocc (GCC) 14.1.0

What operating system are you seeing the problem on?

Linux

Relevant log output

No response

@kedorlaomer kedorlaomer added the medium severity Used to report medium severity bugs (e.g. Malfunctioning Features but still useable) label Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
medium severity Used to report medium severity bugs (e.g. Malfunctioning Features but still useable)
Projects
None yet
Development

No branches or pull requests

1 participant