From 9c80c2b070cd4d9af92a596c47acaee0ef181f06 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Sat, 9 Jul 2016 12:01:51 +0900 Subject: [PATCH] elput - simplify and fix handling of string overflow with xdg runtimedir this addresses an issue pointed to by CID 1357168 --- src/lib/elput/elput_evdev.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/lib/elput/elput_evdev.c b/src/lib/elput/elput_evdev.c index 5393a07..089bad5 100644 --- a/src/lib/elput/elput_evdev.c +++ b/src/lib/elput/elput_evdev.c @@ -60,24 +60,15 @@ _keyboard_modifiers_update(Elput_Keyboard *kbd, Elput_Seat *seat) static int _keyboard_fd_get(off_t size) { - int fd = 0, blen = 0, len = 0; + int fd = 0; const char *path; char tmp[PATH_MAX]; long flags; - blen = sizeof(tmp) - 1; - if (!(path = getenv("XDG_RUNTIME_DIR"))) return -1; - len = strlen(path); - if (len < blen) - { - strcpy(tmp, path); - strcat(tmp, "/elput-keymap-XXXXXX"); - } - else - return -1; + snprintf(tmp, sizeof(tmp), "%s/elput-keymap-XXXXXX", path); fd = eina_file_mkstemp(tmp, NULL); if (fd < 0) return -1; -- 2.7.4