summaryrefslogtreecommitdiff
path: root/libc/termios
diff options
context:
space:
mode:
Diffstat (limited to 'libc/termios')
-rw-r--r--libc/termios/ttyname.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libc/termios/ttyname.c b/libc/termios/ttyname.c
index c9c2c3242..569cfd94e 100644
--- a/libc/termios/ttyname.c
+++ b/libc/termios/ttyname.c
@@ -19,8 +19,8 @@ static int __check_dir_for_tty_match(char * dirname, struct stat *st, char *buf,
len = strlen(dirname) + 1;
while ((d = readdir(fp)) != 0) {
- strncpy(buf+len, d->d_name, buflen);
- buf[buflen]='\0';
+ strncpy(buf+len, d->d_name, buflen-len);
+ buf[buflen-1]='\0';
#if 0
/* Stupid filesystems like cramfs fail to guarantee that
* st_ino and st_dev uniquely identify a file, contrary to