X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Funistd%2Fttyname_r.c;h=8bac7b2f3ab10cb0929341ca1425af65c8d409bf;hb=233767b48a083f526557ee39aa1c773efa345972;hp=f86fbd9c9bccd0dc33c7ab6dacb2dfe17382309c;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01;p=musl diff --git a/src/unistd/ttyname_r.c b/src/unistd/ttyname_r.c index f86fbd9c..8bac7b2f 100644 --- a/src/unistd/ttyname_r.c +++ b/src/unistd/ttyname_r.c @@ -1,7 +1,7 @@ #include #include -#include -#include + +void __procfdname(char *, unsigned); int ttyname_r(int fd, char *name, size_t size) { @@ -10,10 +10,13 @@ int ttyname_r(int fd, char *name, size_t size) if (!isatty(fd)) return ENOTTY; - snprintf(procname, sizeof procname, "/proc/self/fd/%d", fd); + __procfdname(procname, fd); l = readlink(procname, name, size); if (l < 0) return errno; else if (l == size) return ERANGE; - else return 0; + else { + name[l] = 0; + return 0; + } }