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 f86fbd9..2255e2d 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;
+       }
 }