summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2012-06-05 16:42:04 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2012-06-05 16:42:04 +0200
commitaf6a0cf4a160ba1fd83d066b12be94c12e3c1983 (patch)
tree9ea2347532b7bf69356d74bf0278037ad971e0e8
parentDo not allow control characters. (diff)
downloadtelnet-password-honeypot-af6a0cf4a160ba1fd83d066b12be94c12e3c1983.tar.xz
telnet-password-honeypot-af6a0cf4a160ba1fd83d066b12be94c12e3c1983.zip
Fix new line logic so it works with putty too.
-rw-r--r--honeypot.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/honeypot.c b/honeypot.c
index 62e1d0c..9c341b0 100644
--- a/honeypot.c
+++ b/honeypot.c
@@ -153,9 +153,11 @@ void readline(char *buffer, size_t size, int password)
if (feof(input))
_exit(EXIT_SUCCESS);
c = getc(input);
- if (!c)
- c = getc(input);
- if (c == '\n' || c == '\r') {
+ if (c == '\r' || c == '\n') {
+ if (c == '\r') {
+ /* the next char is either \n or \0, which we can discard. */
+ getc(input);
+ }
newline(1);
break;
} else if (c == '\b' || c == 0x7f) {