Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Bugfixes:
* Fixed building with dconf enabled but gio disabled (`-DENABLE_GIO=OFF`). (General)
* Fixed division by zero when calculating disk I/O rates over a sub-millisecond sampling interval. (Top)
* Fixed missing range validation on `--temp-ndigits`, `--percent-ndigits`, `--fraction-ndigits`, and `--freq-ndigits`. (General)

# 2.72.0

Expand Down
2 changes: 1 addition & 1 deletion doc/help.json
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@
{
"long": "fraction-ndigits",
"desc": "Set the number of decimal places to use when printing fractional values",
"remark": "If negative, the number of digits will be automatically determined based on the value",
"remark": "If -1, the number of digits will be automatically determined based on the value",
"arg": {
"type": "num",
"default": -1
Expand Down
28 changes: 24 additions & 4 deletions src/options/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,12 @@ bool ffOptionsParseDisplayCommandLine(FFOptionsDisplay* options, const char* key
{},
});
} else if (ffStrEqualsIgnCase(subkey, "ndigits")) {
options->tempNdigits = (uint8_t) ffOptionParseUInt32(key, value);
uint32_t num = ffOptionParseUInt32(key, value);
if (num > 9) {
fprintf(stderr, "Error: %s must be between 0 and 9\n", key);
exit(479);
}
options->tempNdigits = (uint8_t) num;
} else if (ffStrEqualsIgnCase(subkey, "color-green")) {
ffOptionParseColor(value, &options->tempColorGreen);
} else if (ffStrEqualsIgnCase(subkey, "color-yellow")) {
Expand All @@ -853,7 +858,12 @@ bool ffOptionsParseDisplayCommandLine(FFOptionsDisplay* options, const char* key
if (ffStrEqualsIgnCase(subkey, "type")) {
options->percentType = (uint8_t) ffOptionParseUInt32(key, value);
} else if (ffStrEqualsIgnCase(subkey, "ndigits")) {
options->percentNdigits = (uint8_t) ffOptionParseUInt32(key, value);
uint32_t num = ffOptionParseUInt32(key, value);
if (num > 9) {
fprintf(stderr, "Error: %s must be between 0 and 9\n", key);
exit(479);
}
options->percentNdigits = (uint8_t) num;
} else if (ffStrEqualsIgnCase(subkey, "color-green")) {
ffOptionParseColor(value, &options->percentColorGreen);
} else if (ffStrEqualsIgnCase(subkey, "color-yellow")) {
Expand All @@ -873,7 +883,12 @@ bool ffOptionsParseDisplayCommandLine(FFOptionsDisplay* options, const char* key
return false;
}
} else if (ffStrEqualsIgnCase(key, "--fraction-ndigits")) {
options->fractionNdigits = (int8_t) ffOptionParseInt32(key, value);
int32_t num = ffOptionParseInt32(key, value);
if (num < -1 || num > 9) {
fprintf(stderr, "Error: %s must be between -1 and 9\n", key);
exit(479);
}
options->fractionNdigits = (int8_t) num;
} else if (ffStrEqualsIgnCase(key, "--fraction-trailing-zeros")) {
options->fractionTrailingZeros = (FFFractionTrailingZerosType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) {
{ "default", FF_FRACTION_TRAILING_ZEROS_TYPE_DEFAULT },
Expand Down Expand Up @@ -917,7 +932,12 @@ bool ffOptionsParseDisplayCommandLine(FFOptionsDisplay* options, const char* key
} else if (ffStrStartsWithIgnCase(key, "--freq-")) {
const char* subkey = key + strlen("--freq-");
if (ffStrEqualsIgnCase(subkey, "ndigits")) {
options->freqNdigits = (int8_t) ffOptionParseInt32(key, value);
int32_t num = ffOptionParseInt32(key, value);
if (num < -1 || num > 9) {
fprintf(stderr, "Error: %s must be between -1 and 9\n", key);
exit(479);
}
options->freqNdigits = (int8_t) num;
} else if (ffStrEqualsIgnCase(subkey, "space-before-unit")) {
options->freqSpaceBeforeUnit = (FFSpaceBeforeUnitType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) {
{ "default", FF_SPACE_BEFORE_UNIT_DEFAULT },
Expand Down
Loading