[VDPAU] [PATCH] Detect libflashplayer through /proc/self/maps

Aaron Plattner aplattner at nvidia.com
Tue Nov 19 15:41:11 PST 2013


On 11/12/13 15:44, Jeroen Roovers wrote:
> 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.

Thanks for the patch, Jeroen.

Which browser, specifically, does this patch fix?  All I can glean from 
the discussion above is that this doesn't break Firefox.

-- Aaron

> 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)
>



More information about the VDPAU mailing list