commit 76bcdfa6196f7300b0402cec78f7c802f69908ce
Author: Christophe Fergeau <t...@gnome.org>
Date:   Sun Sep 19 23:01:41 2010 +0200

    Fill GError when HashInfo file is missing
    
    itdb_write_internal only detects errors if the GError it uses is
    filled. No GError was filled when the HashInfo file is missing so
    itdb_write_internal was thinking all was going well when this
    happened instead of reporting an error

 src/itdb_hash72.c  |    9 +++++++--
 src/itdb_private.h |    3 ++-
 src/itdb_sqlite.c  |    2 +-
 3 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/src/itdb_hash72.c b/src/itdb_hash72.c
index 2cbf030..7fada49 100644
--- a/src/itdb_hash72.c
+++ b/src/itdb_hash72.c
@@ -311,12 +311,17 @@ gboolean itdb_hash72_extract_hash_info (const Itdb_Device 
*device,
 
 gboolean itdb_hash72_compute_hash_for_sha1 (const Itdb_Device *device, 
                                            const guchar sha1[20],
-                                           guchar signature[46])
+                                           guchar signature[46],
+                                            GError **error)
 {
     struct Hash78Info *hash_info;
 
     hash_info = read_hash_info (device);
     if (hash_info == NULL) {
+        if (error != NULL) {
+            g_set_error (error, ITDB_FILE_ERROR, ITDB_FILE_ERROR_NOTFOUND,
+                         "Can't write iPod database because of missing 
HashInfo file");
+        }
        return FALSE;
     }
     hash_generate (signature, sha1, hash_info->iv, hash_info->rndpart);
@@ -341,5 +346,5 @@ gboolean itdb_hash72_write_hash (const Itdb_Device *device,
     header = (MhbdHeader *)itdb_data;
     header->hashing_scheme = GUINT16_FROM_LE (ITDB_CHECKSUM_HASH72);
     itdb_hash72_compute_itunesdb_sha1 (itdb_data, itdb_len, sha1);
-    return itdb_hash72_compute_hash_for_sha1 (device, sha1, header->hash72);
+    return itdb_hash72_compute_hash_for_sha1 (device, sha1, header->hash72, 
error);
 }
diff --git a/src/itdb_private.h b/src/itdb_private.h
index 596c670..23f2857 100644
--- a/src/itdb_private.h
+++ b/src/itdb_private.h
@@ -241,7 +241,8 @@ G_GNUC_INTERNAL gboolean itdb_hash58_write_hash 
(Itdb_Device *device,
                                                 GError **error);
 G_GNUC_INTERNAL gboolean itdb_hash72_compute_hash_for_sha1 (const Itdb_Device 
*device, 
                                                            const guchar 
sha1[20],
-                                                           guchar 
signature[46]);
+                                                           guchar 
signature[46],
+                                                           GError **error);
 
 G_GNUC_INTERNAL GByteArray 
*itdb_chapterdata_build_chapter_blob(Itdb_Chapterdata *chapterdata,
                                                                gboolean 
reversed);
diff --git a/src/itdb_sqlite.c b/src/itdb_sqlite.c
index 9b6c64f..4a22578 100644
--- a/src/itdb_sqlite.c
+++ b/src/itdb_sqlite.c
@@ -1908,7 +1908,7 @@ static gboolean mk_Locations_cbk(Itdb_iTunesDB *itdb, 
const char *dirname)
     final_sha1 = &g_array_index(cbk, guchar, CBK_HEADER_SIZE);
     cbk_hash72 = &g_array_index(cbk, guchar, 0);
     success = itdb_hash72_compute_hash_for_sha1 (itdb->device, final_sha1,
-                                                cbk_hash72);
+                                                cbk_hash72, NULL);
     if (!success) {
        g_array_free(cbk, TRUE);
        return FALSE;

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
gtkpod-cvs2 mailing list
gtkpod-cvs2@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to