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

du: runtime error for bad environment value #784

Merged
merged 2 commits into from
Nov 7, 2024

Conversation

mknos
Copy link
Contributor

@mknos 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
@github-actions github-actions bot added Type: enhancement improve a feature that already exists Priority: low get to this whenever Program: du The du program labels Nov 5, 2024
@mknos mknos temporarily deployed to automated_testing November 5, 2024 09:27 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 5, 2024 09:27 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 5, 2024 09:27 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 5, 2024 09:27 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 5, 2024 09:27 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 5, 2024 09:27 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 5, 2024 09:27 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 5, 2024 09:27 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 5, 2024 09:27 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 5, 2024 09:27 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 5, 2024 09:27 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 5, 2024 09:27 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 5, 2024 09:27 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 5, 2024 09:27 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 5, 2024 09:27 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 5, 2024 09:27 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 5, 2024 09:27 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 5, 2024 09:27 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 5, 2024 09:27 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 5, 2024 09:28 — with GitHub Actions Inactive
@coveralls
Copy link

coveralls commented Nov 5, 2024

Pull Request Test Coverage Report for Build 11716823990

Warning: 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

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.7%) to 73.069%

Totals Coverage Status
Change from base Build 11679746948: -0.7%
Covered Lines: 350
Relevant Lines: 479

💛 - 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";
Copy link
Owner

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.

Copy link
Contributor Author

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.

Copy link
Owner

@briandfoy briandfoy left a 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

@briandfoy briandfoy added the Status: changes requested adjust the pull request as noted in comments label Nov 6, 2024
@briandfoy briandfoy self-assigned this Nov 6, 2024
@mknos mknos temporarily deployed to automated_testing November 7, 2024 04:52 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 7, 2024 04:52 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 7, 2024 04:52 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 7, 2024 04:52 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 7, 2024 04:52 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 7, 2024 04:52 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 7, 2024 04:52 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 7, 2024 04:52 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 7, 2024 04:52 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 7, 2024 04:52 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 7, 2024 04:52 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 7, 2024 04:52 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 7, 2024 04:52 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 7, 2024 04:52 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 7, 2024 04:52 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 7, 2024 04:52 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 7, 2024 04:52 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 7, 2024 04:52 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 7, 2024 04:53 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 7, 2024 04:53 — with GitHub Actions Inactive
@briandfoy briandfoy merged commit f1bf501 into briandfoy:master Nov 7, 2024
22 checks passed
@briandfoy
Copy link
Owner

changes: properly handle illegal BLOCKSIZE env values

@briandfoy briandfoy added Status: accepted The fix is accepted and removed Priority: low get to this whenever Status: changes requested adjust the pull request as noted in comments labels Nov 7, 2024
@briandfoy briandfoy added Status: released there is a new release with this fix and removed Status: accepted The fix is accepted labels Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Program: du The du program Status: released there is a new release with this fix Type: enhancement improve a feature that already exists
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants