History

formats+aiff: reject implausibly large number of channels

Helmut Grohne committed 3 years ago

Commit ceffff91 parent 283920f2 files · +13 −2Browse files

Showing the changes to src (2 of 2 files). Show all

Unified · Split

2 files
  1. src/aiff.c +5 −0
  2. src/formats_i.c +8 −2
src/aiff.c+5−0
@@ -619,6 +619,11 @@ int lsx_aiffstartwrite(sox_format_t * ft) · 618 unmodified lines
619619 At 48 kHz, 16 bits stereo, this gives ~3 hours of audio.
620620 Sorry, the AIFF format does not provide for an indefinite
621621 number of samples. */
622+ if (ft->signal.channels >= (0x7f000000 / (ft->encoding.bits_per_sample >> 3)))
623+ {
624+ lsx_fail_errno(ft, SOX_EOF, "too many channels for AIFF header");
625+ return SOX_EOF;
626+ }
622627 return(aiffwriteheader(ft, (uint64_t) 0x7f000000 / ((ft->encoding.bits_per_sample>>3)*ft->signal.channels)));
623628 }
624629
src/formats_i.c+8−2
@@ -19,6 +19,7 @@ · 18 unmodified lines
1919 */
2020
2121 #include "sox_i.h"
22+#include <limits.h>
2223 #include <string.h>
2324 #include <sys/stat.h>
2425 #include <stdarg.h>
@@ -60,9 +61,14 @@ int lsx_check_read_params(sox_format_t * ft, unsigned channels, · 35 unmodified lines
6061 if (ft->seekable)
6162 ft->data_start = lsx_tell(ft);
6263
63− if (channels && ft->signal.channels && ft->signal.channels != channels)
64+ if (channels && ft->signal.channels && ft->signal.channels != channels) {
6465 lsx_warn("`%s': overriding number of channels", ft->filename);
65− else ft->signal.channels = channels;
66+ } else if (channels > SHRT_MAX) {
67+ lsx_fail_errno(ft, EINVAL, "implausibly large number of channels");
68+ return SOX_EOF;
69+ } else {
70+ ft->signal.channels = channels;
71+ }
6672
6773 if (rate && ft->signal.rate && ft->signal.rate != rate)
6874 lsx_warn("`%s': overriding sample rate", ft->filename);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t