Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions va/compat_win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ typedef unsigned int __uid_t;

#if _MSC_VER
#define getenv _getenv
#undef secure_getenv
#define secure_getenv _getenv
#define HAVE_SECURE_GETENV
inline char* _getenv(const char *varname)
Expand Down
13 changes: 0 additions & 13 deletions va/va.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,6 @@

#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))

#ifndef HAVE_SECURE_GETENV
static char * secure_getenv(const char *name)
{
#if defined(__MINGW32__) || defined(__MINGW64__)
if (getuid() == geteuid())
#else
if (getuid() == geteuid() && getgid() == getegid())
#endif
return getenv(name);
else
return NULL;
}
#endif

/*
* read a config "env" for libva.conf or from environment setting
Expand Down
15 changes: 15 additions & 0 deletions va/va_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@
extern "C" {
#endif

#ifndef HAVE_SECURE_GETENV
#ifdef _WIN32
/* No setuid/setgid on Windows, secure_getenv is just getenv */
#define secure_getenv getenv
#else
static inline char * secure_getenv(const char *name)
{
if (getuid() == geteuid() && getgid() == getegid())
return getenv(name);
else
return NULL;
}
#endif
#endif

#define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext)
#define CHECK_DISPLAY(dpy) if (!vaDisplayIsValid(dpy)) { return VA_STATUS_ERROR_INVALID_DISPLAY; }

Expand Down
2 changes: 1 addition & 1 deletion va/x11/va_x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static VAStatus va_DisplayContextGetDriverNames(
{
VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;

if (!getenv("LIBVA_DRI3_DISABLE"))
if (!secure_getenv("LIBVA_DRI3_DISABLE"))
vaStatus = va_DRI3_GetDriverNames(pDisplayContext, drivers, num_drivers);
if (vaStatus != VA_STATUS_SUCCESS)
vaStatus = va_DRI2_GetDriverNames(pDisplayContext, drivers, num_drivers);
Expand Down