ref: ee847e85c9bc170288ea8f129f8aee0b9234eacd
parent: 9f2d60f9cd52a1cc5ae92e02bd862c8cb4b85f13
author: Eric Wong <normalperson@yhbt.net>
date: Wed Nov 8 22:04:27 EST 2017
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 Cc: Joonun Jang <joonun.jang@gmail.com> Cc: 881145@bugs.debian.org
--- a/src/wavpack.c
+++ b/src/wavpack.c
@@ -65,6 +65,10 @@
char msg[80];
p->codec = WavpackOpenFileInputEx(&io_fns, ft, NULL, msg, OPEN_NORMALIZE, 0);
+ if (!p->codec) {
+ lsx_fail_errno(ft, SOX_EHDR, "%s", msg);
+ return SOX_EOF;
+ }
ft->encoding.bits_per_sample = WavpackGetBytesPerSample(p->codec) << 3;
ft->signal.channels = WavpackGetNumChannels(p->codec);
if (WavpackGetSampleRate(p->codec) && ft->signal.rate && ft->signal.rate != WavpackGetSampleRate(p->codec))
@@ -108,6 +112,10 @@
uint64_t size64;
p->codec = WavpackOpenFileOutput(ft_write_b_buf, ft, NULL);
+ if (!p->codec) {
+ lsx_fail_errno(ft, SOX_ENOMEM, "WavPack error creating output instance");
+ return SOX_EOF;
+ }
memset(&config, 0, sizeof(config));
config.bytes_per_sample = ft->encoding.bits_per_sample >> 3;
config.bits_per_sample = ft->encoding.bits_per_sample;