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

head: errors on very large argument to -c but shouldn't #7166

Open
jfinkels opened this issue Jan 19, 2025 · 3 comments
Open

head: errors on very large argument to -c but shouldn't #7166

jfinkels opened this issue Jan 19, 2025 · 3 comments
Labels

Comments

@jfinkels
Copy link
Collaborator

Environment: Ubuntu 20.04, uutils main branch (git commit d39dcad), GNU coreutils v9.6.3-3189c-dirty.

Steps to reproduce:

head --bytes=-18446744073709551616000 < /dev/null

What happens now: uutils head complains that the number is too large:

head: invalid number of bytes: '18446744073709551616000': Value too large for defined data type

What I expected to happen: GNU head terminates successfully with no output.

Notes: this is causing a failure in the GNU test file tests/head/head-c.sh.

@RenjiSann
Copy link
Collaborator

Can we know what the behavior is in case the number of bytes overflows unsigned long long without actually testing it (it would be kind of costly I guess) ? Like is it said somewhere esle than the actual int type in the GNU code ?

If not, maybe we can cap the value to u64::MAX, and assume this will be enough until someone proves us otherwise.

@jfinkels
Copy link
Collaborator Author

Capping the value to u64::MAX is probably good enough to pass the test, I don't know what the GNU head behavior actually is.

@RenjiSann RenjiSann added the good first issue For newcomers! label Feb 24, 2025
@codeOverFlow
Copy link

coreutils state that in case of overflow it would silently cap to MAX value but on any system I try the given command

head --bytes=-18446744073709551616000 < /dev/null

I get the error message
head: invalid number of bytes: '18446744073709551616000': Value too large for defined data type

so not sure if this is not a bad behavior from coreutils

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

3 participants