Skip to content

printf : no infinite loop #5830

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

Merged
merged 3 commits into from
Jan 12, 2024
Merged

printf : no infinite loop #5830

merged 3 commits into from
Jan 12, 2024

Conversation

sudhackar
Copy link
Contributor

Fixes #5815

$ printf a b
a

This PR adds a test for this behaviour. at this moment - the iter from parse_spec_and_escape function won't consume args if no format string is present and goes to an infinite loop.

while args.peek().is_some() {
for item in parse_spec_and_escape(format_string.as_ref()) {
match item?.write(stdout(), &mut args)? {
ControlFlow::Continue(()) => {}
ControlFlow::Break(()) => return Ok(()),
};

@sudhackar
Copy link
Contributor Author

sudhackar commented Jan 12, 2024

failures seem unrelated - "https://busybox.net/downloads/busybox-1.35.0.tar.bz2" is timing out and some issues with termux apt get.

Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

Copy link
Member

@tertsdiepraam tertsdiepraam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Seems correct to me and with a nice test. I just have a small suggestion.

@cakebaker cakebaker merged commit 7e3f4d8 into uutils:main Jan 12, 2024
@cakebaker
Copy link
Contributor

Thanks for your PR :)

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.

printf: infinite loop
3 participants