[easytag/easytag-2-2] Check for an invalid field when reading Vorbis art



commit 18a1d294b7112eb6bf7bc1b14cdef8a205dbbe99
Author: David King <amigadave amigadave com>
Date:   Sun Jan 4 10:41:11 2015 +0000

    Check for an invalid field when reading Vorbis art
    
    When reading cover art from Vorbis comments, check that the
    Base64-decoded data is at least long enough to hold the
    METADATA_BLOCK_PICTURE fields. Mark any invalid files as modified, so
    that the invalid field is removed upon saving.
    
    https://retrace.fedoraproject.org/faf2/problems/516585/

 src/ogg_tag.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/ogg_tag.c b/src/ogg_tag.c
index 9e94af8..8d5892b 100644
--- a/src/ogg_tag.c
+++ b/src/ogg_tag.c
@@ -546,7 +546,7 @@ et_add_file_tags_from_vorbis_comments (vorbis_comment *vc, File_Tag *FileTag,
         Picture *pic;
         gsize bytes_pos, mimelen, desclen;
         guchar *decoded_ustr;
-        gsize decoded_len;
+        gsize decoded_size;
 
         pic = Picture_Allocate();
 
@@ -564,7 +564,19 @@ et_add_file_tags_from_vorbis_comments (vorbis_comment *vc, File_Tag *FileTag,
         pic->data = NULL;
 
         /* Decode picture data. */
-        decoded_ustr = g_base64_decode (string, &decoded_len);
+        decoded_ustr = g_base64_decode (string, &decoded_size);
+
+        /* Check that the comment decoded to a long enough string to hold the
+         * whole structure (8 fields of 4 bytes each). */
+        if (decoded_size < 8 * 4)
+        {
+            /* Mark the file as modified, so that the invalid field is removed
+             * upon saving. */
+            FileTag->saved = FALSE;
+
+            g_free (decoded_ustr);
+            continue;
+        }
 
         /* Reading picture type. */
         pic->type = read_guint32_from_byte (decoded_ustr, 0);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]