clients: sanitize XCURSOR_SIZE

Fixes https://gitlab.freedesktop.org/wayland/weston/issues/164
This commit is contained in:
emersion 2018-11-18 21:42:10 +01:00 committed by Daniel Stone
parent 22dd67ccea
commit ac71ee5d6a

View File

@ -79,6 +79,7 @@ typedef void *EGLContext;
#include "pointer-constraints-unstable-v1-client-protocol.h"
#include "relative-pointer-unstable-v1-client-protocol.h"
#include "shared/os-compatibility.h"
#include "shared/string-helpers.h"
#include "window.h"
@ -89,6 +90,8 @@ typedef void *EGLContext;
#define ZWP_RELATIVE_POINTER_MANAGER_V1_VERSION 1
#define ZWP_POINTER_CONSTRAINTS_V1_VERSION 1
#define DEFAULT_XCURSOR_SIZE 32
struct shm_pool;
struct global {
@ -1340,14 +1343,19 @@ create_cursors(struct display *display)
const char *config_file;
struct weston_config *config;
struct weston_config_section *s;
int size = 32;
char *theme = NULL;
int size = DEFAULT_XCURSOR_SIZE;
char *theme = NULL, *size_str;
unsigned int i, j;
struct wl_cursor *cursor;
theme = getenv("XCURSOR_THEME");
if (getenv("XCURSOR_SIZE"))
size = atoi(getenv("XCURSOR_SIZE"));
size_str = getenv("XCURSOR_SIZE");
if (size_str) {
safe_strtoint(size_str, &size);
if (size <= 0)
size = DEFAULT_XCURSOR_SIZE;
}
config_file = weston_config_get_name_from_env();
config = weston_config_parse(config_file);