Skip to content

Commit b632454

Browse files
authored
du: runtime error for bad environment value
* 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
1 parent 92ea33d commit b632454

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

bin/du

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ $blocksize = $ENV{BLOCKSIZE} if $ENV{BLOCKSIZE}; # use environment if present
3636
getopts('HLPacklrsx') or usage();
3737

3838
$blocksize = 1024 if $opt_k;
39+
if ($blocksize =~ m/[^0-9]/ || $blocksize == 0) {
40+
die "$0: unexpected block size: $blocksize\n";
41+
}
3942

4043
if ($opt_a && $opt_s) {
4144
print STDERR "$0: cannot both summarize and show all entries\n";

0 commit comments

Comments
 (0)