gmediaserver-devel
[Top][All Lists]
Advanced

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

[gmediaserver-devel] segmentation fault if there are no details for url-


From: Gerd Hofmann
Subject: [gmediaserver-devel] segmentation fault if there are no details for url-entry in playlist (contentdir.c get_entry_property)
Date: Sun, 12 Dec 2010 20:28:20 +0100
User-agent: Mozilla-Thunderbird 2.0.0.24 (X11/20100329)

There is a BUG in function get_entry_property in contentdir.c (cvs and previous versions).

  if (strcmp(property, "upnp:class") == 0) {
      if (has_entry_detail(entry, DETAIL_CHILDREN))
          return xstrdup("object.container.storageFolder");
      /*if (has_entry_detail(entry, DETAIL_URL))
          return xstrdup("object.item.audioItem.audioBroadcast");*/

      detail = get_entry_detail(entry, DETAIL_FILE);
      switch (detail->data.file.item_class) {
      case ITEM_AUDIO:
          return xstrdup("object.item.audioItem.musicTrack");
      case ITEM_IMAGE:
          return xstrdup("object.item.imageItem.photo");
      case ITEM_VIDEO:
          return xstrdup("object.item.videoItem.movie");
      case ITEM_PLAYLIST:
      case ITEM_TEXT:
      case ITEM_UNKNOWN:
      default:
          /* FIXME */
          return NULL;
      }
  }

A NULL-pointer check is missing after the call to get_entry_detail.
In my case there were no details (detail == NULL) for an url in a playlist.
So the next line ended up in a segmentation fault.

The following patch for contentdir.c from cvs fixes this issue:

--- contentdir.c.dist    2007-11-29 21:06:53.000000000 +0100
+++ contentdir.c    2010-12-12 11:57:37.000000000 +0100
@@ -101,20 +101,24 @@
           return xstrdup("object.item.audioItem.audioBroadcast");*/
               detail = get_entry_detail(entry, DETAIL_FILE);
-        switch (detail->data.file.item_class) {
-        case ITEM_AUDIO:
-            return xstrdup("object.item.audioItem.musicTrack");
-        case ITEM_IMAGE:
-            return xstrdup("object.item.imageItem.photo");
-        case ITEM_VIDEO:
-            return xstrdup("object.item.videoItem.movie");
-        case ITEM_PLAYLIST:
-        case ITEM_TEXT:
-        case ITEM_UNKNOWN:
-        default:
-            /* FIXME */
-            return NULL;
+        if(detail) {
+            switch (detail->data.file.item_class) {
+            case ITEM_AUDIO:
+                return xstrdup("object.item.audioItem.musicTrack");
+            case ITEM_IMAGE:
+                return xstrdup("object.item.imageItem.photo");
+            case ITEM_VIDEO:
+                return xstrdup("object.item.videoItem.movie");
+            case ITEM_PLAYLIST:
+            case ITEM_TEXT:
+            case ITEM_UNKNOWN:
+            default:
+                /* FIXME */
+                return NULL;
+            }
       }
+        else
+            return NULL;
   }

   if (detail != NULL) {


Gerd




reply via email to

[Prev in Thread] Current Thread [Next in Thread]