Revision: 2344
          http://gtkpod.svn.sourceforge.net/gtkpod/?rev=2344&view=rev
Author:   teuf
Date:     2009-05-02 19:22:44 +0000 (Sat, 02 May 2009)

Log Message:
-----------
Make sure pointers are valid when necessary.

1. m53 might be null. Check before dereferencing to count.
2. Since there is an assert for artwork->thunmbnail->data_type, we
   have to check artwork->thumbnail before. Not after. So do
   an assert on that pointer too.
3. If props is null both itdb_sysinfo_properties_dump and
   itdb_sysinfo_properties_free will segfault. Better to just return.

Modified Paths:
--------------
    libgpod/trunk/ChangeLog
    libgpod/trunk/src/itdb_itunesdb.c
    libgpod/trunk/src/ithumb-writer.c
    libgpod/trunk/tests/test-sysinfo-extended-parsing.c

Modified: libgpod/trunk/ChangeLog
===================================================================
--- libgpod/trunk/ChangeLog     2009-05-02 19:05:12 UTC (rev 2343)
+++ libgpod/trunk/ChangeLog     2009-05-02 19:22:44 UTC (rev 2344)
@@ -1,5 +1,20 @@
 2009-05-02  Christophe Fergeau  <[email protected]>
 
+       Patch from: Erik Hovland <[email protected]>
+
+       Make sure pointers are valid when necessary.
+
+       * src/itdb_itunesdb.c: m53 might be null. Check before dereferencing
+       to count.
+       * src/ithumb-writer.c: Since there is an assert for
+       artwork->thunmbnail->data_type, we have to check artwork->thumbnail 
+       before. Not after. So do an assert on that pointer too.
+       * tests/test-sysinfo-extended-parsing.c: If props is null both 
+       itdb_sysinfo_properties_dump and itdb_sysinfo_properties_free 
+       will segfault. Better to just return.
+
+2009-05-02  Christophe Fergeau  <[email protected]>
+
        * src/ithumb-writer.c: readd needed include
 
 2009-05-02  Christophe Fergeau  <[email protected]>

Modified: libgpod/trunk/src/itdb_itunesdb.c
===================================================================
--- libgpod/trunk/src/itdb_itunesdb.c   2009-05-02 19:05:12 UTC (rev 2343)
+++ libgpod/trunk/src/itdb_itunesdb.c   2009-05-02 19:22:44 UTC (rev 2344)
@@ -4317,6 +4317,7 @@
              lastsortkey = sortkey; 
            }
            mhod53index++;
+           g_assert (m53 != NULL);
            m53->count++;
          }
       }

Modified: libgpod/trunk/src/ithumb-writer.c
===================================================================
--- libgpod/trunk/src/ithumb-writer.c   2009-05-02 19:05:12 UTC (rev 2343)
+++ libgpod/trunk/src/ithumb-writer.c   2009-05-02 19:22:44 UTC (rev 2344)
@@ -1125,21 +1125,19 @@
                  Itdb_Artwork *artwork, 
                  Itdb_Thumb_Ipod *thumb_ipod)
 {
+        g_assert (artwork->thumbnail);
         g_assert (artwork->thumbnail->data_type != ITDB_THUMB_TYPE_IPOD);
 
-       if (artwork->thumbnail)
-       {
-           /* check if new thumbnail file has to be started */
-           if (ithumb_writer_update (writer)) {
-                Itdb_Thumb_Ipod_Item *item;
-                item = ithumb_writer_write_thumbnail (writer, 
-                                                      artwork->thumbnail);
-                if (item != NULL) {
-                    itdb_thumb_ipod_add (thumb_ipod, item);
-                }
-
+       /* check if new thumbnail file has to be started */
+       if (ithumb_writer_update (writer)) {
+            Itdb_Thumb_Ipod_Item *item;
+            item = ithumb_writer_write_thumbnail (writer, 
+                                                  artwork->thumbnail);
+            if (item != NULL) {
+                itdb_thumb_ipod_add (thumb_ipod, item);
             }
-       }
+
+        }
 }
 
 

Modified: libgpod/trunk/tests/test-sysinfo-extended-parsing.c
===================================================================
--- libgpod/trunk/tests/test-sysinfo-extended-parsing.c 2009-05-02 19:05:12 UTC 
(rev 2343)
+++ libgpod/trunk/tests/test-sysinfo-extended-parsing.c 2009-05-02 19:22:44 UTC 
(rev 2344)
@@ -14,6 +14,7 @@
     props = itdb_sysinfo_extended_parse (argv[1], &error);
     if (props == NULL) {
         g_print ("Couldn't parse %s: %s\n", argv[1], error->message);
+        return(2);
     }
     itdb_sysinfo_properties_dump (props);
     itdb_sysinfo_properties_free (props);


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to