Remove chance of undefined behavior corner case

This commit is contained in:
Shea Levy 2011-09-24 13:23:52 -04:00
parent 9b93d57d9c
commit bde5a8e076

View File

@ -51,11 +51,11 @@ char* freerdp_passphrase_read(const char* prompt, char* buf, size_t bufsiz)
buf_iter = buf;
while ((nbytes = read(term_id, &read_char, sizeof read_char)) == (sizeof read_char))
{
read_bytes++;
if (read_char == '\n')
break;
if (read_bytes < bufsiz)
if (read_bytes < (bufsiz - (size_t) 1))
{
read_bytes++;
*buf_iter = read_char;
buf_iter++;
}