diff -N -p -u -r libvdpau-0.4.orig/configure.ac libvdpau-0.4/configure.ac
--- libvdpau-0.4.orig/configure.ac	2015-09-01 20:00:37.049229000 +0200
+++ libvdpau-0.4/configure.ac	2015-09-01 20:00:51.293219000 +0200
@@ -6,6 +6,10 @@ AM_MAINTAINER_MODE
 
 AM_CONFIG_HEADER(config.h)
 
+# Check for secure_getenv
+AC_USE_SYSTEM_EXTENSIONS
+AC_CHECK_FUNCS([__secure_getenv secure_getenv])
+
 # Disable static libraries by default.  Use --enable-static if you really want
 # them.
 AC_DISABLE_STATIC
diff -N -p -u -r libvdpau-0.4.orig/configure.ac.orig libvdpau-0.4/configure.ac.orig
diff -N -p -u -r libvdpau-0.4.orig/src/Makefile.am libvdpau-0.4/src/Makefile.am
--- libvdpau-0.4.orig/src/Makefile.am	2015-09-01 20:00:36.713219000 +0200
+++ libvdpau-0.4/src/Makefile.am	2015-09-01 20:00:51.591246000 +0200
@@ -8,6 +8,7 @@ lib_LTLIBRARIES = libvdpau.la
 
 libvdpau_la_SOURCES = \
     vdpau_wrapper.c \
+    util.h \
     $(DRI2_SOURCES)
 
 if DRI2
diff -N -p -u -r libvdpau-0.4.orig/src/Makefile.am.orig libvdpau-0.4/src/Makefile.am.orig
diff -N -p -u -r libvdpau-0.4.orig/src/mesa_dri2.c libvdpau-0.4/src/mesa_dri2.c
--- libvdpau-0.4.orig/src/mesa_dri2.c	2015-09-01 20:00:36.711200000 +0200
+++ libvdpau-0.4/src/mesa_dri2.c	2015-09-01 20:00:51.628213000 +0200
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2008 Red Hat, Inc.
- * Copyright © 2010 NVIDIA Corporation
+ * Copyright © 2010-2015 NVIDIA Corporation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Soft-
@@ -30,6 +30,7 @@
  * Authors:
  *   Kristian Høgsberg (krh@redhat.com)
  *   Modified for VDPAU by Aaron Plattner (aplattner@nvidia.com)
+ *   and José Hiram Soltren (jsoltren@nvidia.com)
  */
 
 
@@ -39,6 +40,7 @@
 #include <X11/extensions/extutil.h>
 #include <X11/extensions/dri2proto.h>
 #include "mesa_dri2.h"
+#include "util.h"
 
 static char dri2ExtensionName[] = DRI2_NAME;
 static XExtensionInfo *dri2Info;
diff -N -p -u -r libvdpau-0.4.orig/src/util.h libvdpau-0.4/src/util.h
--- libvdpau-0.4.orig/src/util.h	1970-01-01 01:00:00.000000000 +0100
+++ libvdpau-0.4/src/util.h	2015-09-01 20:00:51.640215000 +0200
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015 NVIDIA Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <unistd.h>
+#include <stdlib.h>
+
+static char * getenv_wrapper(const char *name)
+{
+    if (getuid() == geteuid() && getgid() == getegid()) {
+        return getenv(name);
+    }
+    else {
+        return NULL;
+    }
+}
+
+#ifndef HAVE_SECURE_GETENV
+#  ifdef HAVE___SECURE_GETENV
+#    define secure_getenv __secure_getenv
+#  else
+#    warning Neither secure_getenv nor __secure_getenv is available.
+#    define secure_getenv getenv_wrapper
+#  endif
+#endif
diff -N -p -u -r libvdpau-0.4.orig/src/vdpau_wrapper.c libvdpau-0.4/src/vdpau_wrapper.c
--- libvdpau-0.4.orig/src/vdpau_wrapper.c	2015-09-01 20:00:36.726230000 +0200
+++ libvdpau-0.4/src/vdpau_wrapper.c	2015-09-01 20:00:51.656251000 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008-2009 NVIDIA, Corporation
+ * Copyright (c) 2008-2015 NVIDIA Corporation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -35,6 +35,7 @@
 #include "mesa_dri2.h"
 #include <X11/Xlib.h>
 #endif
+#include "util.h"
 
 typedef void SetDllHandle(
     void * driver_dll_handle
@@ -104,7 +105,12 @@ VdpStatus vdp_device_create_x11(
 
     VdpDeviceCreateX11 * vdp_imp_device_create_x11;
 
-    vdpau_driver = getenv("VDPAU_DRIVER");
+    vdpau_driver = secure_getenv("VDPAU_DRIVER");
+    if (vdpau_driver) {
+        if (strchr(vdpau_driver, '/')) {
+            vdpau_driver = NULL;
+        }
+    }
     if (!vdpau_driver) {
         vdpau_driver = vdpau_driver_dri2 =
             _vdp_get_driver_name_from_dri2(display, screen);
@@ -145,7 +151,7 @@ VdpStatus vdp_device_create_x11(
         return VDP_STATUS_NO_IMPLEMENTATION;
     }
 
-    vdpau_trace = getenv("VDPAU_TRACE");
+    vdpau_trace = secure_getenv("VDPAU_TRACE");
     if (vdpau_trace && atoi(vdpau_trace)) {
         void *         trace_dll;
         SetDllHandle * set_dll_handle;
diff -N -p -u -r libvdpau-0.4.orig/src/vdpau_wrapper.c.orig libvdpau-0.4/src/vdpau_wrapper.c.orig
diff -N -p -u -r libvdpau-0.4.orig/trace/vdpau_trace.cpp libvdpau-0.4/trace/vdpau_trace.cpp
--- libvdpau-0.4.orig/trace/vdpau_trace.cpp	2015-09-01 20:00:36.807208000 +0200
+++ libvdpau-0.4/trace/vdpau_trace.cpp	2015-09-01 20:00:51.673239000 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008-2009 NVIDIA, Corporation
+ * Copyright (c) 2008-2015 NVIDIA Corporation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -31,6 +31,8 @@
 #include <string.h>
 #include <vdpau/vdpau_x11.h>
 
+#include "../src/util.h"
+
 #define _VDP_TRACE_ARSIZE(_x_) ((sizeof (_x_)) / (sizeof ((_x_)[0])))
 
 #if DEBUG
@@ -4575,13 +4577,13 @@ VdpStatus vdp_trace_device_create_x11(
     }
     else {
         _vdp_cap_data.level = 0;
-        char const * vdpau_trace = getenv("VDPAU_TRACE");
+        char const * vdpau_trace = secure_getenv("VDPAU_TRACE");
         if (vdpau_trace) {
             _vdp_cap_data.level = atoi(vdpau_trace);
         }
 
         _vdp_cap_data.fp = 0;
-        char const * vdpau_trace_file = getenv("VDPAU_TRACE_FILE");
+        char const * vdpau_trace_file = secure_getenv("VDPAU_TRACE_FILE");
         if (vdpau_trace_file && strlen(vdpau_trace_file)) {
             if (vdpau_trace_file[0] == '&') {
                 int fd = atoi(&vdpau_trace_file[1]);
