ref: 3ccca3b8b82cbd2a146110b07cbf7fd867de8ead
parent: ceffff92190351bc83dc94fbfb72dc31a481ceea
author: Helmut Grohne <helmut@subdivi.de>
date: Wed Aug 16 22:02:22 EDT 2023
formats: reject implausible rate
--- a/src/formats_i.c
+++ b/src/formats_i.c
@@ -70,9 +70,15 @@
ft->signal.channels = channels;
}
- if (rate && ft->signal.rate && ft->signal.rate != rate)
+ if (rate && ft->signal.rate && ft->signal.rate != rate) {
lsx_warn("`%s': overriding sample rate", ft->filename);
- else ft->signal.rate = rate;
+ /* Since NaN comparisons yield false, the negation rejects them. */
+ } else if (!(rate > 0)) {
+ lsx_fail_errno(ft, EINVAL, "invalid rate value");
+ return SOX_EOF;
+ } else {
+ ft->signal.rate = rate;
+ }
if (encoding && ft->encoding.encoding && ft->encoding.encoding != encoding)
lsx_warn("`%s': overriding encoding type", ft->filename);