-
Notifications
You must be signed in to change notification settings - Fork 53
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
du: runtime error for bad environment value #784
Conversation
mknos
commented
Nov 5, 2024
- Add validation that $blocksize must be a positive integer
- Setting BLOCKSIZE="-0" would result in a division by zero
- Possibly du doesn't need to access any environment variables, but for now keep BLOCKSIZE
* Add validation that $blocksize must be a positive integer * Setting BLOCKSIZE="-0" would result in a division by zero * Possibly du doesn't need to access any environment variables, but for now keep BLOCKSIZE
Pull Request Test Coverage Report for Build 11716823990Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
bin/du
Outdated
@@ -36,6 +36,9 @@ $blocksize = $ENV{BLOCKSIZE} if $ENV{BLOCKSIZE}; # use environment if present | |||
getopts('HLPacklrsx') or usage(); | |||
|
|||
$blocksize = 1024 if $opt_k; | |||
if ($blocksize =~ m/[^0-9]/ || $blocksize == 0) { | |||
die "$0: unexpected block size: $blocksize\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
du on archlinux returns 1
, FreeBSD returns 64 (for -B
), and so on. I'd prefer some value that isn't die
's 255.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've added a new commit and there are no longer any calls to die() in the du command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a better exit value
changes: properly handle illegal BLOCKSIZE env values |