diff options
author | Brooks Davis <brooks@FreeBSD.org> | 2017-04-24 22:37:54 +0000 |
---|---|---|
committer | Brooks Davis <brooks@FreeBSD.org> | 2017-04-24 22:37:54 +0000 |
commit | 1918f96ef0b44d7866392083e26c37be973909cd (patch) | |
tree | d04d5cee23f5a1785d67ca3cf978fe49dcc26389 | |
parent | 7005e48904b767a7ed8825cc79a62fc7814913fe (diff) |
Notes
-rw-r--r-- | lib/libc/gen/ttyname.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/libc/gen/ttyname.c b/lib/libc/gen/ttyname.c index 02aa1587e14db..6628e3b44b2b9 100644 --- a/lib/libc/gen/ttyname.c +++ b/lib/libc/gen/ttyname.c @@ -61,6 +61,10 @@ ttyname_r(int fd, char *buf, size_t len) { size_t used; + /* Don't write off the end of a zero-length buffer. */ + if (len < 1) + return (ERANGE); + *buf = '\0'; /* Must be a terminal. */ |