]> granicus.if.org Git - sudo/commitdiff
Add a check for devname() returning a fully-qualified pathname.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 12 Jan 2012 12:50:40 +0000 (07:50 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 12 Jan 2012 12:50:40 +0000 (07:50 -0500)
None of the devname() implementations do this today but you never
know when this might change.

src/sudo.c

index bb515f1d558d0a889335b19895cfbd5d85387cf8..87b388e876252af3e61f1cf8687bc3b6e5cd418e 100644 (file)
@@ -479,12 +479,15 @@ get_process_tty(void)
                sudo_debug_printf(SUDO_DEBUG_WARN,
                    "unable to map device number %u to name",
                    ki_proc->sudo_kp_tdev);
-           } else {
+           } else if (*dev != '/') {
                /* devname() doesn't use the /dev/ prefix, add one... */
                size_t len = sizeof(_PATH_DEV) + strlen(dev);
                tty = emalloc(len);
                strlcpy(tty, _PATH_DEV, len);
                strlcat(tty, dev, len);
+           } else {
+               /* Should not happen but just in case... */
+               tty = estrdup(dev);
            }
        } else {
            sudo_debug_printf(SUDO_DEBUG_WARN,