Update ttyname_r to current coding conventions.

This commit is contained in:
Jonas 'Sortie' Termansen 2015-02-04 17:17:45 +01:00
parent f384fcdff1
commit 56267517ec
1 changed files with 2 additions and 3 deletions

View File

@ -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;
}