From c0683bc2dd361612a8e285f4966e715aed690b85 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 10 Feb 2015 16:23:17 -0500 Subject: [PATCH] ecore-drm should not use sscanf when getting logind vt this should be more robust for when something like "/dev/tty4" is passed @fix --- src/lib/ecore_drm/ecore_drm_logind.c | 17 ++++++++++++----- 1 file 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 d4db3b9..f820756 100644 --- a/src/lib/ecore_drm/ecore_drm_logind.c +++ b/src/lib/ecore_drm/ecore_drm_logind.c @@ -1,4 +1,5 @@ #include "ecore_drm_private.h" +#include #ifndef KDSKBMUTE # define KDSKBMUTE 0x4B51 @@ -11,7 +12,7 @@ static inline Eina_Bool _ecore_drm_logind_vt_get(Ecore_Drm_Device *dev) { int ret; - char *tty; + char *tty, *p; ret = sd_session_get_tty(dev->session, &tty); if (ret < 0) @@ -20,12 +21,18 @@ _ecore_drm_logind_vt_get(Ecore_Drm_Device *dev) return EINA_FALSE; } - ret = sscanf(tty, "tty%u", &dev->vt); + p = strchr(tty, 't'); + dev->vt = UINT_MAX; + if (p) + { + while (p[0] && (!isdigit(p[0]))) + p++; + if (p[0]) + dev->vt = strtoul(p, NULL, 10); + } free(tty); - if (ret != 1) return EINA_FALSE; - - return EINA_TRUE; + return dev->vt != UINT_MAX; } #endif -- 2.7.4