Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/tag/Id3Load.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <algorithm>

static constexpr size_t ID3V1_SIZE = 128;
static constexpr size_t MAX_ID3_TAG_SIZE = 4 * 1024 * 1024;

[[gnu::pure]]
static inline bool
Expand Down Expand Up @@ -46,6 +47,8 @@ try {
return nullptr;

const std::size_t tag_size = static_cast<std::size_t>(query);
if (tag_size > MAX_ID3_TAG_SIZE)
return nullptr;

/* Found a tag. Allocate a buffer and read it in. */
if (tag_size <= sizeof(query_buffer))
Expand Down Expand Up @@ -185,7 +188,7 @@ try {
if (size == 0)
return nullptr;

if (size > 4 * 1024 * 1024)
if (size > MAX_ID3_TAG_SIZE)
/* too large, don't allocate so much memory */
return nullptr;

Expand Down
Loading