Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/gen Prefix devname's buffer with /dev/ as ttyname i...



details:   https://anonhg.NetBSD.org/src/rev/63ea1dded849
branches:  trunk
changeset: 779703:63ea1dded849
user:      joerg <joerg%NetBSD.org@localhost>
date:      Tue Jun 12 18:17:04 2012 +0000

description:
Prefix devname's buffer with /dev/ as ttyname is supposed to return the
full path. Reported by Dave Huang.

diffstat:

 lib/libc/gen/ttyname.c |  9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diffs (37 lines):

diff -r d37f5288c15d -r 63ea1dded849 lib/libc/gen/ttyname.c
--- a/lib/libc/gen/ttyname.c    Tue Jun 12 17:26:29 2012 +0000
+++ b/lib/libc/gen/ttyname.c    Tue Jun 12 18:17:04 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ttyname.c,v 1.25 2012/06/03 21:42:46 joerg Exp $       */
+/*     $NetBSD: ttyname.c,v 1.26 2012/06/12 18:17:04 joerg Exp $       */
 
 /*
  * Copyright (c) 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)ttyname.c  8.2 (Berkeley) 1/27/94";
 #else
-__RCSID("$NetBSD: ttyname.c,v 1.25 2012/06/03 21:42:46 joerg Exp $");
+__RCSID("$NetBSD: ttyname.c,v 1.26 2012/06/12 18:17:04 joerg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -45,6 +45,7 @@
 #include <assert.h>
 #include <errno.h>
 #include <limits.h>
+#include <paths.h>
 #include <string.h>
 #include <stdlib.h>
 #include <termios.h>
@@ -79,6 +80,10 @@
        if (fstat(fd, &sb))
                return errno;
 
+       if (strlcpy(buf, _PATH_DEV, len) >= len)
+               return ERANGE;
+       buf += strlen(_PATH_DEV);
+       len -= strlen(_PATH_DEV);
        return devname_r(sb.st_rdev, sb.st_mode & S_IFMT, buf, len);
 }
 



Home | Main Index | Thread Index | Old Index