summaryrefslogtreecommitdiff
path: root/src/lib/ecore_drm
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2015-02-10 16:23:17 -0500
committerMike Blumenkrantz <zmike@osg.samsung.com>2015-02-10 16:24:39 -0500
commitc0683bc2dd361612a8e285f4966e715aed690b85 (patch)
treeee97ccc67f38b90d5d96bf9865f5c6540385a496 /src/lib/ecore_drm
parentb5011fa867efed123986b340b3187c8147ab5524 (diff)
ecore-drm should not use sscanf when getting logind vt
this should be more robust for when something like "/dev/tty4" is passed @fix
Diffstat (limited to 'src/lib/ecore_drm')
-rw-r--r--src/lib/ecore_drm/ecore_drm_logind.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/lib/ecore_drm/ecore_drm_logind.c b/src/lib/ecore_drm/ecore_drm_logind.c
index d4db3b92bc..f8207567cd 100644
--- a/src/lib/ecore_drm/ecore_drm_logind.c
+++ b/src/lib/ecore_drm/ecore_drm_logind.c
@@ -1,4 +1,5 @@
1#include "ecore_drm_private.h" 1#include "ecore_drm_private.h"
2#include <ctype.h>
2 3
3#ifndef KDSKBMUTE 4#ifndef KDSKBMUTE
4# define KDSKBMUTE 0x4B51 5# define KDSKBMUTE 0x4B51
@@ -11,7 +12,7 @@ static inline Eina_Bool
11_ecore_drm_logind_vt_get(Ecore_Drm_Device *dev) 12_ecore_drm_logind_vt_get(Ecore_Drm_Device *dev)
12{ 13{
13 int ret; 14 int ret;
14 char *tty; 15 char *tty, *p;
15 16
16 ret = sd_session_get_tty(dev->session, &tty); 17 ret = sd_session_get_tty(dev->session, &tty);
17 if (ret < 0) 18 if (ret < 0)
@@ -20,12 +21,18 @@ _ecore_drm_logind_vt_get(Ecore_Drm_Device *dev)
20 return EINA_FALSE; 21 return EINA_FALSE;
21 } 22 }
22 23
23 ret = sscanf(tty, "tty%u", &dev->vt); 24 p = strchr(tty, 't');
25 dev->vt = UINT_MAX;
26 if (p)
27 {
28 while (p[0] && (!isdigit(p[0])))
29 p++;
30 if (p[0])
31 dev->vt = strtoul(p, NULL, 10);
32 }
24 free(tty); 33 free(tty);
25 34
26 if (ret != 1) return EINA_FALSE; 35 return dev->vt != UINT_MAX;
27
28 return EINA_TRUE;
29} 36}
30#endif 37#endif
31 38