[easytag] Check for a valid MP3 file when reading the header



commit 13844449f413a66410d230e4494011b15513a484
Author: David King <amigadave amigadave com>
Date:   Sat Feb 14 20:02:28 2015 +0000

    Check for a valid MP3 file when reading the header
    
    The check to avoid an infinite loop in id3lib with an empty file was
    only run when reading ID3 tags, not when reading the header information.

 src/tags/id3_tag.c     |    5 +----
 src/tags/id3_tag.h     |    1 +
 src/tags/mpeg_header.c |    7 +++++++
 3 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/tags/id3_tag.c b/src/tags/id3_tag.c
index f5a8805..7dd65ac 100644
--- a/src/tags/id3_tag.c
+++ b/src/tags/id3_tag.c
@@ -67,9 +67,6 @@ ID3_C_EXPORT size_t ID3Tag_Link_1         (ID3Tag *id3tag, const char *filename)
 ID3_C_EXPORT size_t ID3Field_GetASCII_1   (const ID3Field *field, char *buffer,      size_t maxChars, size_t 
itemNum);
 ID3_C_EXPORT size_t ID3Field_GetUNICODE_1 (const ID3Field *field, unicode_t *buffer, size_t maxChars, size_t 
itemNum);
 
-static gboolean et_id3tag_check_if_file_is_valid (GFile *file,
-                                                  GError **error);
-
 static gboolean id3tag_check_if_id3lib_is_buggy (GError **error);
 
 
@@ -1388,7 +1385,7 @@ Id3tag_Rules_For_ISO_Fields (const gchar *string,
  * Some files which contains only zeroes create an infinite loop in id3lib...
  * To generate a file with zeroes : dd if=/dev/zero bs=1M count=6 of=test-corrupted-mp3-zero-contend.mp3
  */
-static gboolean
+gboolean
 et_id3tag_check_if_file_is_valid (GFile *file, GError **error)
 {
     unsigned char tmp[256];
diff --git a/src/tags/id3_tag.h b/src/tags/id3_tag.h
index fd72dcc..ff26cb9 100644
--- a/src/tags/id3_tag.h
+++ b/src/tags/id3_tag.h
@@ -35,6 +35,7 @@ const gchar * Id3tag_Genre_To_String (unsigned char genre_code);
 guchar Id3tag_String_To_Genre (const gchar *genre);
 
 gchar *et_id3tag_get_tpos_from_file_tag (const File_Tag *file_tag);
+gboolean et_id3tag_check_if_file_is_valid (GFile *file, GError **error);
 
 G_END_DECLS
 
diff --git a/src/tags/mpeg_header.c b/src/tags/mpeg_header.c
index d4b2cef..dfccbbf 100644
--- a/src/tags/mpeg_header.c
+++ b/src/tags/mpeg_header.c
@@ -24,6 +24,7 @@
 #include <glib/gi18n.h>
 #include <errno.h>
 
+#include "id3_tag.h"
 #include "mpeg_header.h"
 #include "misc.h"
 
@@ -80,6 +81,12 @@ et_mpeg_header_read_file_info (GFile *file,
     g_return_val_if_fail (file != NULL || ETFileInfo != NULL, FALSE);
     g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
+    /* Check if the file is corrupt. */
+    if (!et_id3tag_check_if_file_is_valid (file, error))
+    {
+        return FALSE;
+    }
+
     /* Get size of file */
     info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE,
                               G_FILE_QUERY_INFO_NONE, NULL, error);


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