summaryrefslogtreecommitdiff
path: root/src/lib/elput/elput_evdev.c
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-07-09 12:01:51 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-07-09 12:01:51 +0900
commit9c80c2b070cd4d9af92a596c47acaee0ef181f06 (patch)
tree8b462f7bed5d11c0dc099aae34d6bacd4cc6df16 /src/lib/elput/elput_evdev.c
parent870c81fd7282a355f9bdcf298ef87cb374575bdb (diff)
elput - simplify and fix handling of string overflow with xdg runtimedir
this addresses an issue pointed to by CID 1357168
Diffstat (limited to '')
-rw-r--r--src/lib/elput/elput_evdev.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/src/lib/elput/elput_evdev.c b/src/lib/elput/elput_evdev.c
index 5393a07c8d..089bad513c 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)
60static int 60static int
61_keyboard_fd_get(off_t size) 61_keyboard_fd_get(off_t size)
62{ 62{
63 int fd = 0, blen = 0, len = 0; 63 int fd = 0;
64 const char *path; 64 const char *path;
65 char tmp[PATH_MAX]; 65 char tmp[PATH_MAX];
66 long flags; 66 long flags;
67 67
68 blen = sizeof(tmp) - 1;
69
70 if (!(path = getenv("XDG_RUNTIME_DIR"))) 68 if (!(path = getenv("XDG_RUNTIME_DIR")))
71 return -1; 69 return -1;
72 70
73 len = strlen(path); 71 snprintf(tmp, sizeof(tmp), "%s/elput-keymap-XXXXXX", path);
74 if (len < blen)
75 {
76 strcpy(tmp, path);
77 strcat(tmp, "/elput-keymap-XXXXXX");
78 }
79 else
80 return -1;
81 72
82 fd = eina_file_mkstemp(tmp, NULL); 73 fd = eina_file_mkstemp(tmp, NULL);
83 if (fd < 0) return -1; 74 if (fd < 0) return -1;