DSF ID3 tags hitting 4k size limit
Here's a change to dynamically allocate the DSD ID3 tag buffer. Pretty much anything with cover art is going to exceed the existing, static 4k limit... Here's a change to dynamically allocate the buffer and sanity check it at some upper limit. I rather arbitrarily pulled 256k out of thin air just to keep a corrupt file from causing it to trying to allocate a buffer larger than available memory.
This commit is contained in:
parent
e38faca455
commit
35db88affe
2
NEWS
2
NEWS
|
@ -1,4 +1,6 @@
|
||||||
ver 0.19.8 (not yet released)
|
ver 0.19.8 (not yet released)
|
||||||
|
* decoder
|
||||||
|
- dsdiff, dsf: allow ID3 tags larger than 4 kB
|
||||||
|
|
||||||
ver 0.19.7 (2014/12/17)
|
ver 0.19.7 (2014/12/17)
|
||||||
* input
|
* input
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "input/InputStream.hxx"
|
#include "input/InputStream.hxx"
|
||||||
#include "tag/TagId3.hxx"
|
#include "tag/TagId3.hxx"
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
|
#include "util/Alloc.hxx"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -123,22 +124,27 @@ dsdlib_tag_id3(InputStream &is,
|
||||||
|
|
||||||
const id3_length_t count = size - offset;
|
const id3_length_t count = size - offset;
|
||||||
|
|
||||||
/* Check and limit id3 tag size to prevent a stack overflow */
|
if (count < 10 || count > 256*1024)
|
||||||
id3_byte_t dsdid3[4096];
|
|
||||||
if (count == 0 || count > sizeof(dsdid3))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!decoder_read_full(nullptr, is, dsdid3, count))
|
id3_byte_t *const id3_buf = static_cast<id3_byte_t*>(xalloc(count));
|
||||||
return;
|
|
||||||
|
|
||||||
struct id3_tag *id3_tag = id3_tag_parse(dsdid3, count);
|
if (!decoder_read_full(nullptr, is, id3_buf, count)) {
|
||||||
if (id3_tag == nullptr)
|
free(id3_buf);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct id3_tag *id3_tag = id3_tag_parse(id3_buf, count);
|
||||||
|
if (id3_tag == nullptr) {
|
||||||
|
free(id3_buf);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
scan_id3_tag(id3_tag, handler, handler_ctx);
|
scan_id3_tag(id3_tag, handler, handler_ctx);
|
||||||
|
|
||||||
id3_tag_delete(id3_tag);
|
id3_tag_delete(id3_tag);
|
||||||
|
|
||||||
|
free(id3_buf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue