From 7db84a961aa117d8e8d355819fc70f91670ca956 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 12 Jul 2014 20:41:21 +0200 Subject: [PATCH 1/4] decoder/dsdiff: fix metadata parser bug (uninitialized variables) --- NEWS | 1 + src/decoder/DsdiffDecoderPlugin.cxx | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 7acf48cc9..924d8cd2b 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,7 @@ ver 0.18.12 (not yet released) - audiofile: improve responsiveness - audiofile: fix WAV stream playback - dsdiff, dsf: fix stream playback + - dsdiff: fix metadata parser bug (uninitialized variables) - faad: estimate song duration for remote files - sndfile: improve responsiveness * randomize next song when enabling "random" mode while not playing diff --git a/src/decoder/DsdiffDecoderPlugin.cxx b/src/decoder/DsdiffDecoderPlugin.cxx index f8506851a..4eee71711 100644 --- a/src/decoder/DsdiffDecoderPlugin.cxx +++ b/src/decoder/DsdiffDecoderPlugin.cxx @@ -250,8 +250,11 @@ dsdiff_read_metadata_extra(Decoder *decoder, InputStream &is, if (!dsdiff_read_chunk_header(decoder, is, chunk_header)) return false; + metadata->diar_offset = 0; + metadata->diti_offset = 0; + #ifdef HAVE_ID3TAG - metadata->id3_size = 0; + metadata->id3_offset = 0; #endif /* Now process all the remaining chunk headers in the stream From 85f4aeca05ba51e3081fe0ddc7f463d64be5dce8 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 12 Jul 2014 20:39:55 +0200 Subject: [PATCH 2/4] decoder/dsdiff: ignore garbage null byte at end of file Failure to read another chunk header is not fatal. Continue to read metadata. --- src/decoder/DsdiffDecoderPlugin.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/decoder/DsdiffDecoderPlugin.cxx b/src/decoder/DsdiffDecoderPlugin.cxx index 4eee71711..dba921de5 100644 --- a/src/decoder/DsdiffDecoderPlugin.cxx +++ b/src/decoder/DsdiffDecoderPlugin.cxx @@ -294,7 +294,7 @@ dsdiff_read_metadata_extra(Decoder *decoder, InputStream &is, if (is.GetOffset() < size) { if (!dsdiff_read_chunk_header(decoder, is, chunk_header)) - return false; + break; } } /* done processing chunk headers, process tags if any */ From a73834436fb3947aa69d571026171c16d2434cec Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 12 Jul 2014 20:46:24 +0200 Subject: [PATCH 3/4] decoder/dsdiff: simplify loop condition, merge branches --- src/decoder/DsdiffDecoderPlugin.cxx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/decoder/DsdiffDecoderPlugin.cxx b/src/decoder/DsdiffDecoderPlugin.cxx index dba921de5..5d9a679da 100644 --- a/src/decoder/DsdiffDecoderPlugin.cxx +++ b/src/decoder/DsdiffDecoderPlugin.cxx @@ -260,8 +260,7 @@ dsdiff_read_metadata_extra(Decoder *decoder, InputStream &is, /* Now process all the remaining chunk headers in the stream and record their position and size */ - const auto size = is.GetSize(); - while (is.GetOffset() < size) { + do { uint64_t chunk_size = chunk_header->GetSize(); /* DIIN chunk, is directly followed by other chunks */ @@ -291,12 +290,8 @@ dsdiff_read_metadata_extra(Decoder *decoder, InputStream &is, if (!dsdlib_skip(decoder, is, chunk_size)) break; } + } while (dsdiff_read_chunk_header(decoder, is, chunk_header)); - if (is.GetOffset() < size) { - if (!dsdiff_read_chunk_header(decoder, is, chunk_header)) - break; - } - } /* done processing chunk headers, process tags if any */ #ifdef HAVE_ID3TAG From 94efeb284582643cfdbca248c2f4e4647be09f63 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 12 Jul 2014 20:51:00 +0200 Subject: [PATCH 4/4] decoder/dsdiff: simplify dsdlib_skip() call --- src/decoder/DsdiffDecoderPlugin.cxx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/decoder/DsdiffDecoderPlugin.cxx b/src/decoder/DsdiffDecoderPlugin.cxx index 5d9a679da..60b2e7624 100644 --- a/src/decoder/DsdiffDecoderPlugin.cxx +++ b/src/decoder/DsdiffDecoderPlugin.cxx @@ -286,10 +286,9 @@ dsdiff_read_metadata_extra(Decoder *decoder, InputStream &is, metadata->id3_size = chunk_size; } #endif - if (chunk_size != 0) { - if (!dsdlib_skip(decoder, is, chunk_size)) - break; - } + + if (!dsdlib_skip(decoder, is, chunk_size)) + break; } while (dsdiff_read_chunk_header(decoder, is, chunk_header)); /* done processing chunk headers, process tags if any */