History

wavpack: check errors when initializing

+Cc sox-devel. Joonun: thank you for reporting, the following patch should fix the problem. I guess make sure sox-devel knows about any other bugs you find; original upstream developers seem to busy so it's mostly Måns and I. I don't think either of us have permission to the SourceForge.net project; either... Will also try to look at https://bugs.debian.org/881121 soon (maybe Måns can help). -----------8<--------- From: Eric Wong <e@80x24.org> Subject: [PATCH] wavpack: check errors when initializing Avoid NULL dereference when opening an WavPack input file fails as described by Debian Bug #881145. While we're at it, check for malloc failures when opening an output file to avoid other NULL dereference bugs. cf. https://bugs.debian.org/881145

Eric Wong committed 9 years ago

Commit ee847e81 parent 9f2d60f1 file · +8 −0Browse files

Unified · Split

src/wavpack.c+8−0
@@ -65,6 +65,10 @@ static int start_read(sox_format_t * ft) · 64 unmodified lines
65 char msg[80];65 char msg[80];
66 66
67 p->codec = WavpackOpenFileInputEx(&io_fns, ft, NULL, msg, OPEN_NORMALIZE, 0);67 p->codec = WavpackOpenFileInputEx(&io_fns, ft, NULL, msg, OPEN_NORMALIZE, 0);
68 if (!p->codec) {
69 lsx_fail_errno(ft, SOX_EHDR, "%s", msg);
70 return SOX_EOF;
71 }
68 ft->encoding.bits_per_sample = WavpackGetBytesPerSample(p->codec) << 3;72 ft->encoding.bits_per_sample = WavpackGetBytesPerSample(p->codec) << 3;
69 ft->signal.channels = WavpackGetNumChannels(p->codec);73 ft->signal.channels = WavpackGetNumChannels(p->codec);
70 if (WavpackGetSampleRate(p->codec) && ft->signal.rate && ft->signal.rate != WavpackGetSampleRate(p->codec))74 if (WavpackGetSampleRate(p->codec) && ft->signal.rate && ft->signal.rate != WavpackGetSampleRate(p->codec))
@@ -108,6 +112,10 @@ static int start_write(sox_format_t * ft) · 37 unmodified lines
108 uint64_t size64;112 uint64_t size64;
109 113
110 p->codec = WavpackOpenFileOutput(ft_write_b_buf, ft, NULL);114 p->codec = WavpackOpenFileOutput(ft_write_b_buf, ft, NULL);
115 if (!p->codec) {
116 lsx_fail_errno(ft, SOX_ENOMEM, "WavPack error creating output instance");
117 return SOX_EOF;
118 }
111 memset(&config, 0, sizeof(config));119 memset(&config, 0, sizeof(config));
112 config.bytes_per_sample = ft->encoding.bits_per_sample >> 3;120 config.bytes_per_sample = ft->encoding.bits_per_sample >> 3;
113 config.bits_per_sample = ft->encoding.bits_per_sample;121 config.bits_per_sample = ft->encoding.bits_per_sample;

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