]> granicus.if.org Git - musl/commitdiff
fix broken ttyname[_r] (failure to null-terminate result)
authorRich Felker <dalias@aerifal.cx>
Fri, 7 Sep 2012 00:21:13 +0000 (20:21 -0400)
committerRich Felker <dalias@aerifal.cx>
Fri, 7 Sep 2012 00:21:13 +0000 (20:21 -0400)
src/unistd/ttyname_r.c

index f86fbd9c9bccd0dc33c7ab6dacb2dfe17382309c..2255e2dfebb7a5c2e8378e38879792dba88476f0 100644 (file)
@@ -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;
+       }
 }