1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

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

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