[vlc-devel] [PATCH] Udev SD: Try to find out the mount point for blu-ray discs.

Konstantin Pavlov thresh at videolan.org
Wed Feb 15 17:18:40 CET 2012


On Wed, Feb 15, 2012 at 04:39:02PM +0100, Rémi Denis-Courmont wrote:
> >> > +        while ((m = getmntent_r (mtab, &mbuf, buf, sizeof(buf))) !=
> >> NULL)
> >> > +        {
> >> > +            if( !strcmp (m->mnt_fsname, val)) val = m->mnt_dir;
> >> > +        }
> >> > +        endmntent (mtab);
> >> > +    }
> >> > +
> >> >      return make_URI (val, scheme);
> >> 
> >> This looks like use-after-release to me.
> > 
> > Uhm, why?
> 
> val = m->mnt_dir... I don't suppose the storage for that is still valid.

The attached patch doesnt re-use val.

-- 
Konstantin Pavlov
VideoLAN team
-------------- next part --------------
>From 49a422acb85fc410c1fb80840ef97b418835a62f Mon Sep 17 00:00:00 2001
From: Konstantin Pavlov <thresh at videolan.org>
Date: Wed, 15 Feb 2012 16:30:38 +0400
Subject: [PATCH] Udev SD: Try to find out the mount point for blu-ray discs.

---
 modules/services_discovery/udev.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/modules/services_discovery/udev.c b/modules/services_discovery/udev.c
index 56b42e2..c9b6dee 100644
--- a/modules/services_discovery/udev.c
+++ b/modules/services_discovery/udev.c
@@ -34,6 +34,7 @@
 #endif
 #include <poll.h>
 #include <errno.h>
+#include <mntent.h>
 
 static int OpenV4L (vlc_object_t *);
 #ifdef HAVE_ALSA
@@ -576,6 +577,24 @@ static char *disc_get_mrl (struct udev_device *dev)
         return NULL;
 
     val = udev_device_get_devnode (dev);
+
+    if (!strcmp (scheme, "bluray"))
+    {
+        FILE* mtab = setmntent ("/proc/self/mounts", "r");
+        struct mntent* m;
+        struct mntent mbuf;
+        char buf [8192];
+        while ((m = getmntent_r (mtab, &mbuf, buf, sizeof(buf))) != NULL)
+        {
+            if (!strcmp (m->mnt_fsname, val))
+            {
+                endmntent (mtab);
+                return make_URI (m->mnt_dir, scheme);
+            }
+        }
+        endmntent (mtab);
+    }
+
     return make_URI (val, scheme);
 }
 
-- 
1.7.8.4



More information about the vlc-devel mailing list