From bde5a8e076937b6ef3263f92d4a49e4b51060a2b Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sat, 24 Sep 2011 13:23:52 -0400 Subject: [PATCH] Remove chance of undefined behavior corner case --- libfreerdp-utils/passphrase.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libfreerdp-utils/passphrase.c b/libfreerdp-utils/passphrase.c index 7caa3dbf2..58b3e2091 100644 --- a/libfreerdp-utils/passphrase.c +++ b/libfreerdp-utils/passphrase.c @@ -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++; }