From 56267517ec027a246c79f2558135a7615d574330 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Wed, 4 Feb 2015 17:17:45 +0100 Subject: [PATCH] Update ttyname_r to current coding conventions. --- libc/unistd/ttyname_r.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libc/unistd/ttyname_r.cpp b/libc/unistd/ttyname_r.cpp index b604914a..98e63bed 100644 --- a/libc/unistd/ttyname_r.cpp +++ b/libc/unistd/ttyname_r.cpp @@ -31,8 +31,7 @@ extern "C" int ttyname_r(int fd, char* path, size_t path_size) if ( isatty(fd) < 1 ) return -1; const char* result = "/dev/tty"; - size_t result_length = strlen(result); - if ( result_length + 1 < path_size ) + if ( path_size <= strlcpy(path, result, path_size) ) return errno = ERANGE, -1; - return strcpy(path, result), 0; + return 0; }