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

printf does not have limits for the maximum value of its arguments #1879

Closed
jaggededgedjustice opened this issue Mar 22, 2021 · 7 comments
Closed

Comments

@jaggededgedjustice
Copy link
Contributor

The GNU printf command limits the value of arguments it will accept, for example

$ printf '%.*d\n' 10 0
0000000000
$ printf '%.*d\n' 2147483648 0
bash: printf: warning: 0: Numerical result out of range

The version of printf in this repo does not apply this limit so it will produce 2 billion 0s. This is causing the gnu tests to fail when attempting to generate the final log as it has to process a log from a test that is ~2GB in size.

If this isn't considered a bug then the gnu tests should be patched to remove the problematic check.

@tdulcet
Copy link

tdulcet commented Mar 23, 2021

Note that your example is using the Bash built-in printf, which produces different output then GNU printf in this case:

$ printf '%.*d\n' 2147483648 0
-bash: printf: warning: 0: Numerical result out of range

$ /usr/bin/printf '%.*d\n' 2147483648 0
/usr/bin/printf: invalid precision: ‘2147483648’

@stale
Copy link

stale bot commented Jan 13, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 13, 2023
@tertsdiepraam
Copy link
Member

Hasn't been fixed yet

@stale stale bot removed the wontfix label Jan 13, 2023
@howjmay
Copy link
Contributor

howjmay commented Mar 9, 2023

Hi @tertsdiepraam if possible I want to give this a try. But what is the maximum acceptable range of a valid output?

@tertsdiepraam
Copy link
Member

tertsdiepraam commented Mar 9, 2023

@howjmay I've tried some values and the maximum allowed value in GNU seems to be 2^31 - 1 = 2147483647. So basically whatever fits in a i32 I suppose.

@howjmay
Copy link
Contributor

howjmay commented Mar 9, 2023

Thank you!

howjmay added a commit to howjmay/coreutils that referenced this issue Mar 11, 2023
sylvestre pushed a commit to howjmay/coreutils that referenced this issue Apr 28, 2023
@cakebaker
Copy link
Contributor

Fixed in #6511

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

Successfully merging a pull request may close this issue.

5 participants