diff options
author | Brooks Davis <brooks@FreeBSD.org> | 2017-04-13 15:52:45 +0000 |
---|---|---|
committer | Brooks Davis <brooks@FreeBSD.org> | 2017-04-13 15:52:45 +0000 |
commit | 8439a7220d6eb183195967c09724b3064a23c684 (patch) | |
tree | 1e2a6400f5674ad14341201faf07fc0fbb130641 | |
parent | 33c72b24dee54cd9f5ccab28478fd5a8b5876944 (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 7ca73b7b42b39..153b8d2878dd7 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. */ |