ecore_drm: Verifying if name format is /dev/xyz before assigning to tty.
authorSrivardhan Hebbar <sri.hebbar@samsung.com>
Mon, 6 Oct 2014 13:12:38 +0000 (09:12 -0400)
committerChris Michael <cp.michael@samsung.com>
Mon, 6 Oct 2014 13:14:30 +0000 (09:14 -0400)
Summary: Because this is an exposed API function, we should be
checking that the name parameter is valid, and also verify it's
formatting before we use it. This patch fixes that by comparing the
passed in name and assembling a valid tty name to open

@fix

Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com>
Reviewers: devilhorns

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D1521

src/lib/ecore_drm/ecore_drm_tty.c

index c04749431104b46c349122ab080c34884cf14401..c6246985e7b3482a9bbf2d359a3134c000b3e8a4 100644 (file)
@@ -205,8 +205,13 @@ ecore_drm_tty_open(Ecore_Drm_Device *dev, const char *name)
         else
           dev->tty.fd = dup(STDIN_FILENO);
      }
-   else // FIXME: NB: This should Really check for format of name (/dev/xyz)
-     snprintf(tty, sizeof(tty), "%s", name);
+   else
+     {
+        if (strncmp(name,"/dev/", 5))
+          snprintf(tty, sizeof(tty), "/dev/%s",name);
+        else
+          snprintf(tty, sizeof(tty), "%s", name);
+     }
 
    if (dev->tty.fd < 0)
      {