commit 3b0fbb713febed42eeb98227453965e94b99e187
Author: Hector Martin <[email protected]>
Date:   Thu Oct 29 23:16:59 2009 +0100

    Fix 0xa8 in header (presumed to be compression enable)

 src/itdb_itunesdb.c |    3 +++
 src/itdb_zlib.c     |   31 +++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/src/itdb_itunesdb.c b/src/itdb_itunesdb.c
index 187b73c..eb29945 100644
--- a/src/itdb_itunesdb.c
+++ b/src/itdb_itunesdb.c
@@ -2895,6 +2895,9 @@ static gboolean parse_fimp (FImport *fimp, gboolean 
compressed)
     CHECK_ERROR (fimp, FALSE);
     fimp->itdb->priv->unk_0xa8 = get32lint (cts, seek+0xA8);
     CHECK_ERROR (fimp, FALSE);
+    if(fimp->itdb->priv->unk_0xa8 != 0) {
+       g_warning ("Unknown value for 0xa8 in header: should be 0 for 
uncompressed, is %d.\n", fimp->itdb->priv->unk_0xa8);
+    }
 
     if (mhsd_1 == -1)
     {   /* Very bad: no type 1 mhsd which should hold the tracklist */
diff --git a/src/itdb_zlib.c b/src/itdb_zlib.c
index 0b769f1..4e9a277 100644
--- a/src/itdb_zlib.c
+++ b/src/itdb_zlib.c
@@ -117,6 +117,21 @@ gboolean itdb_zlib_check_decompress_fimp (FImport *fimp)
     headerSize = *(guint32*)(cts->contents+4);
     uSize = 0;
 
+    if (headerSize < 0xA9) {
+       g_set_error (&fimp->error,
+                    ITDB_FILE_ERROR,
+                    ITDB_FILE_ERROR_ITDB_CORRUPT,
+                    _("Header is too small for iTunesCDB!\n"));
+       return FALSE;
+    }
+
+    /* compression flag */
+    if (*(guint8*)(cts->contents+0xa8) == 1) {
+       *(guint8*)(cts->contents+0xa8) = 0;
+    } else {
+       g_warning ("Unknown value for 0xa8 in header: should be 1 for 
uncompressed, is %d.\n", *(guint8*)(cts->contents+0xa8));
+    }
+
     if (zlib_inflate(NULL, cts->contents+headerSize, cSize-headerSize, &uSize) 
== 0) {
        gchar *new_contents;
        g_print("allocating %"G_GSIZE_FORMAT"\n", uSize+headerSize);
@@ -157,6 +172,22 @@ gboolean itdb_zlib_check_compress_fexp (FExport *fexp)
 
     header_len = GUINT32_FROM_LE (*(guint32*)(cts->contents+4));
     uncompressed_len = GUINT32_FROM_LE(*(guint32*)(cts->contents+8)) - 
header_len;
+
+    if (header_len < 0xA9) {
+       g_set_error (&fexp->error,
+                    ITDB_FILE_ERROR,
+                    ITDB_FILE_ERROR_ITDB_CORRUPT,
+                    _("Header is too small for iTunesCDB!\n"));
+       return FALSE;
+    }
+
+    /* compression flag */
+    if (*(guint8*)(cts->contents+0xa8) == 0) {
+       *(guint8*)(cts->contents+0xa8) = 1;
+    } else {
+       g_warning ("Unknown value for 0xa8 in header: should be 0 for 
uncompressed, is %d.\n", *(guint8*)(cts->contents+0xa8));
+    }
+
     compressed_len = compressBound (uncompressed_len);
 
     new_contents = g_malloc (header_len + compressed_len);

------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to