From fcfba99503746e44585d7e318562dd425e8ff390 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 6 Sep 2012 20:21:13 -0400 Subject: fix broken ttyname[_r] (failure to null-terminate result) --- src/unistd/ttyname_r.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/unistd/ttyname_r.c b/src/unistd/ttyname_r.c index f86fbd9c..2255e2df 100644 --- a/src/unistd/ttyname_r.c +++ b/src/unistd/ttyname_r.c @@ -15,5 +15,8 @@ int ttyname_r(int fd, char *name, size_t size) if (l < 0) return errno; else if (l == size) return ERANGE; - else return 0; + else { + name[l] = 0; + return 0; + } } -- cgit v1.2.1