Error out when asked to store an picture that is too large

Picture size must be smaller than the maximum block size.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
This commit is contained in:
Erik de Castro Lopo
2016-01-09 10:42:39 +11:00
parent 27e00c8be0
commit d9f73a8ce6
2 changed files with 8 additions and 1 deletions

View File

@@ -1799,6 +1799,9 @@ FLAC_API FLAC__bool FLAC__metadata_object_picture_set_data(FLAC__StreamMetadata
FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_PICTURE);
FLAC__ASSERT((0 != data && length > 0) || (0 == data && length == 0 && copy == false));
if(length >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN))
return false;
old = object->data.picture.data;
/* do the copy first so that if we fail we leave the object untouched */

View File

@@ -273,7 +273,8 @@ static const char *error_messages[] = {
"invalid picture type",
"unable to guess MIME type from file, user must set explicitly",
"type 1 icon must be a 32x32 pixel PNG",
"file not found"
"file not found", /* currently unused */
"file is too large"
};
static const char * read_file (const char * filepath, FLAC__StreamMetadata * obj)
@@ -286,6 +287,9 @@ static const char * read_file (const char * filepath, FLAC__StreamMetadata * obj
if (size < 0)
return error_messages[5];
if (size >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN))
return error_messages[11];
if ((buffer = safe_malloc_(size)) == NULL)
return error_messages[0];