Skip to content

Commit

Permalink
Limit bitrate range to 31 bits integer
Browse files Browse the repository at this point in the history
A proper solution could be to use "long long" instead (guaranteed to be
at least 64 bits), but it adds its own problems (e.g. "%lld" is not
supported as a printf format on all platforms).

In practice, we don't need such high values, so keep it simple.

Fixes #995 <#995>
  • Loading branch information
rom1v committed Dec 10, 2019
1 parent 71df317 commit 6965d05
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ parse_integer_arg(const char *s, long *out, bool accept_suffix, long min,
static bool
parse_bit_rate(const char *s, uint32_t *bit_rate) {
long value;
bool ok = parse_integer_arg(s, &value, true, 0, 0xFFFFFFFF, "bit-rate");
// long may be 32 bits (it is the case on mingw), so do not use more than
// 31 bits (long is signed)
bool ok = parse_integer_arg(s, &value, true, 0, 0x7FFFFFFF, "bit-rate");
if (!ok) {
return false;
}
Expand Down

0 comments on commit 6965d05

Please sign in to comment.