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

ts_conf: Fix unbounded write by scanf() #205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

szsam
Copy link

@szsam szsam commented May 25, 2023

Buffer write operations that do not control the length of data written may overflow.

Also, the scanf format string "%[^\n]s" is ill-formed. It contains two independent format specifiers: "%[^\n]" followed by a lone "s". This will direct scanf to read everything until \n is encountered (leaving \n unread), and then require that the next input character is s. This just doesn't make any sense. No input will match such self-contradictory format.
Reference: https://stackoverflow.com/questions/8177752/scanf-ns-a-vs-getsa

Buffer write operations that do not control the length of data
written may overflow.

Also, the scanf format string "%[^\n]s" is ill-formed. It contains
two independent format specifiers: "%[^\n]" followed by a lone "s".
This will direct scanf to read everything until \n is encountered
(leaving \n unread), and then require that the next input character
is s. This just doesn't make any sense. No input will match such
self-contradictory format.
Reference: https://stackoverflow.com/questions/8177752/scanf-ns-a-vs-getsa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant