diff options
Diffstat (limited to 'src/decoder/plugins/DsdLib.cxx')
-rw-r--r-- | src/decoder/plugins/DsdLib.cxx | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/decoder/plugins/DsdLib.cxx b/src/decoder/plugins/DsdLib.cxx index d826970f7..8fefbb48c 100644 --- a/src/decoder/plugins/DsdLib.cxx +++ b/src/decoder/plugins/DsdLib.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -34,7 +34,7 @@ #include <string.h> #include <stdlib.h> -#ifdef HAVE_ID3TAG +#ifdef ENABLE_ID3TAG #include <id3tag.h> #endif @@ -48,7 +48,7 @@ DsdId::Equals(const char *s) const } /** - * Skip the #input_stream to the specified offset. + * Skip the #InputStream to the specified offset. */ bool dsdlib_skip_to(Decoder *decoder, InputStream &is, @@ -64,7 +64,7 @@ dsdlib_skip_to(Decoder *decoder, InputStream &is, } /** - * Skip some bytes from the #input_stream. + * Skip some bytes from the #InputStream. */ bool dsdlib_skip(Decoder *decoder, InputStream &is, @@ -103,31 +103,29 @@ dsdlib_valid_freq(uint32_t samplefreq) } } -#ifdef HAVE_ID3TAG +#ifdef ENABLE_ID3TAG void dsdlib_tag_id3(InputStream &is, const struct tag_handler *handler, - void *handler_ctx, int64_t tagoffset) + void *handler_ctx, offset_type tagoffset) { - assert(tagoffset >= 0); - if (tagoffset == 0 || !is.KnownSize()) return; - if (!dsdlib_skip_to(nullptr, is, tagoffset)) - return; - /* Prevent broken files causing problems */ const auto size = is.GetSize(); - const auto offset = is.GetOffset(); - if (offset >= size) + if (tagoffset >= size) return; - const id3_length_t count = size - offset; + const auto count64 = size - tagoffset; + if (count64 < 10 || count64 > 1024 * 1024) + return; - if (count < 10 || count > 1024 * 1024) + if (!dsdlib_skip_to(nullptr, is, tagoffset)) return; + const id3_length_t count = count64; + id3_byte_t *const id3_buf = new id3_byte_t[count]; if (id3_buf == nullptr) return; |