[VDPAU] [PATCH] Detect libflashplayer through /proc/self/maps
Jeroen Roovers
jer at gentoo.org
Tue Nov 12 15:44:53 PST 2013
Parsing /proc/self/cmdline does not always detect libflashplayer since
not every browser includes that string. /proc/self/maps will always map
the library we are looking for, so we use that instead.
Signed-off-by: Jeroen Roovers <jer at gentoo.org>
---
src/vdpau_wrapper.c | 27 ++++++++-------------------
1 file changed, 8 insertions(+), 19 deletions(-)
diff --git a/src/vdpau_wrapper.c b/src/vdpau_wrapper.c
index 9932937..a665dd9 100644
--- a/src/vdpau_wrapper.c
+++ b/src/vdpau_wrapper.c
@@ -301,31 +301,20 @@ static void init_running_under_flash(void)
{
FILE *fp;
char buffer[1024];
- int ret, i;
- fp = fopen("/proc/self/cmdline", "r");
+ fp = fopen("/proc/self/maps", "r");
if (!fp) {
return;
}
- ret = fread(buffer, 1, sizeof(buffer) - 1, fp);
- fclose(fp);
- if (ret < 0) {
- return;
- }
- /*
- * Sometimes the file contains null between arguments. Wipe these out so
- * strstr doesn't stop early.
- */
- for (i = 0; i < ret; i++) {
- if (buffer[i] == '\0') {
- buffer[i] = 'x';
- }
- }
- buffer[ret] = '\0';
- if (strstr(buffer, "libflashplayer") != NULL) {
- _running_under_flash = 1;
+ while( fgets(buffer, sizeof(buffer), fp)) {
+ if (strstr(buffer, "libflashplayer") != NULL)
+ _running_under_flash = 1;
+ break;
}
+
+ fclose(fp);
+
}
static void init_config(void)
--
1.8.3.2
More information about the VDPAU
mailing list