about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-09-06 20:21:13 -0400
committerRich Felker <dalias@aerifal.cx>2012-09-06 20:21:13 -0400
commitfcfba99503746e44585d7e318562dd425e8ff390 (patch)
tree9000cee083d90ae4c8f859ab0061766a5e9b9b25
parentfb247fafa04ee52dda816355ab0461132297b9a4 (diff)
downloadmusl-fcfba99503746e44585d7e318562dd425e8ff390.tar.gz
musl-fcfba99503746e44585d7e318562dd425e8ff390.tar.xz
musl-fcfba99503746e44585d7e318562dd425e8ff390.zip
fix broken ttyname[_r] (failure to null-terminate result)
-rw-r--r--src/unistd/ttyname_r.c5
1 files changed, 4 insertions, 1 deletions
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;
+	}
 }