-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for
zstd
CLI accepts bogus values for numeric parameters (#3268)
* add checks to mal-formed numeric values for memory and memlimit parameters Signed-off-by: Ly Cao <lycao@fb.com> * changed errorMsg to a literal string instead of static string in main * moved bogus numeric error to NEXT_UINT32 + add macro NEXT_TSIZE Signed-off-by: Ly Cao <lycao@fb.com> Signed-off-by: Ly Cao <lycao@fb.com> Co-authored-by: Ly Cao <lycao@fb.com>
- Loading branch information
Showing
4 changed files
with
82 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/sh | ||
|
||
echo "some data" > file | ||
|
||
println "+ zstd --memory=32LB file" | ||
zstd --memory=32LB file && die "Should not allow bogus suffix" | ||
println "+ zstd --memory=32LiB file" | ||
zstd --memory=32LiB file && die "Should not allow bogus suffix" | ||
println "+ zstd --memory=32A file" | ||
zstd --memory=32A file && die "Should not allow bogus suffix" | ||
println "+ zstd --memory=32r82347dn83 file" | ||
zstd --memory=32r82347dn83 file && die "Should not allow bogus suffix" | ||
println "+ zstd --memory=32asbdf file" | ||
zstd --memory=32asbdf file && die "Should not allow bogus suffix" | ||
println "+ zstd --memory=hello file" | ||
zstd --memory=hello file && die "Should not allow non-numeric parameter" | ||
println "+ zstd --memory=1 file" | ||
zstd --memory=1 file && die "Should allow numeric parameter without suffix" | ||
rm file.zst | ||
println "+ zstd --memory=1K file" | ||
zstd --memory=1K file && die "Should allow numeric parameter with expected suffix" | ||
rm file.zst | ||
println "+ zstd --memory=1KB file" | ||
zstd --memory=1KB file && die "Should allow numeric parameter with expected suffix" | ||
rm file.zst | ||
println "+ zstd --memory=1KiB file" | ||
zstd --memory=1KiB file && die "Should allow numeric parameter with expected suffix" | ||
rm file.zst | ||
println "+ zstd --memory=1M file" | ||
zstd --memory=1M file && die "Should allow numeric parameter with expected suffix" | ||
rm file.zst | ||
println "+ zstd --memory=1MB file" | ||
zstd --memory=1MB file && die "Should allow numeric parameter with expected suffix" | ||
rm file.zst | ||
println "+ zstd --memory=1MiB file" | ||
zstd --memory=1MiB file && die "Should allow numeric parameter with expected suffix" | ||
rm file.zst | ||
|
||
rm file | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error: only numeric values with optional suffixes K, KB, KiB, M, MB, MiB are allowed | ||
error: only numeric values with optional suffixes K, KB, KiB, M, MB, MiB are allowed | ||
error: only numeric values with optional suffixes K, KB, KiB, M, MB, MiB are allowed | ||
error: only numeric values with optional suffixes K, KB, KiB, M, MB, MiB are allowed | ||
error: only numeric values with optional suffixes K, KB, KiB, M, MB, MiB are allowed | ||
error: only numeric values with optional suffixes K, KB, KiB, M, MB, MiB are allowed | ||
Should allow numeric parameter without suffix | ||
Should allow numeric parameter with expected suffix | ||
Should allow numeric parameter with expected suffix | ||
Should allow numeric parameter with expected suffix | ||
Should allow numeric parameter with expected suffix | ||
Should allow numeric parameter with expected suffix | ||
Should allow numeric parameter with expected suffix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
+ zstd --memory=32LB file | ||
+ zstd --memory=32LiB file | ||
+ zstd --memory=32A file | ||
+ zstd --memory=32r82347dn83 file | ||
+ zstd --memory=32asbdf file | ||
+ zstd --memory=hello file | ||
+ zstd --memory=1 file | ||
+ zstd --memory=1K file | ||
+ zstd --memory=1KB file | ||
+ zstd --memory=1KiB file | ||
+ zstd --memory=1M file | ||
+ zstd --memory=1MB file | ||
+ zstd --memory=1MiB file |