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

Problems with zero precision #26

Closed
ghost opened this issue Sep 13, 2018 · 2 comments
Closed

Problems with zero precision #26

ghost opened this issue Sep 13, 2018 · 2 comments
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Sep 13, 2018

There are some problems with a precision of 0 (an annoying corner case).

The following crash:

  • printf("% .0d", 0); (should output )
  • printf("%+.0d", 0); (should output +)

This is caused by decrementing a 0 len here: https://github.com/mpaland/printf/blob/master/printf.c#L185

printf("%#.0x", 0); is apparently supposed to output an empty string, not 0x. The octal case is correct, though. It seems this was clarified in C11.

@mpaland
Copy link
Owner

mpaland commented Sep 14, 2018

Wow! This is really serious and leads to out of bounds buffer access!
Wondering that coverity didn't catch it.

@mpaland mpaland self-assigned this Sep 14, 2018
@mpaland mpaland added the bug label Sep 14, 2018
@eyalroz
Copy link

eyalroz commented Jul 21, 2021

The fix for this bug may have causes #109 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants