Skip to content

printf : no infinite loop#5830

Merged
cakebaker merged 3 commits intouutils:mainfrom
sudhackar:printf-infinite-loop
Jan 12, 2024
Merged

printf : no infinite loop#5830
cakebaker merged 3 commits intouutils:mainfrom
sudhackar:printf-infinite-loop

Conversation

@sudhackar
Copy link
Copy Markdown
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
Copy Markdown
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.

@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

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

Copy link
Copy Markdown
Collaborator

@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
Copy Markdown
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