From d9d0d5e3ccdaddb55b0e8458f24461144b806602 Mon Sep 17 00:00:00 2001 From: Kevin Lange Date: Fri, 14 Feb 2014 00:58:56 -0800 Subject: [PATCH] Fix telnet size negotiation --- CHANGELOG | 3 +++ Makefile | 2 +- src/nyancat.c | 9 ++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 99853c4..a4fd4e8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +1.4.1 + * Fix telnet size negotiation + 1.4 * Added better terminal size autodetection * Fixed rendering when requested size was larger than diff --git a/Makefile b/Makefile index a8a9638..4a574ae 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ package = nyancat -version = 1.4 +version = 1.4.1 tarname = $(package) distdir = $(tarname)-$(version) diff --git a/src/nyancat.c b/src/nyancat.c index e71cc61..97c9b6e 100644 --- a/src/nyancat.c +++ b/src/nyancat.c @@ -342,7 +342,7 @@ int main(int argc, char ** argv) { int k, ttype; uint32_t option = 0, done = 0, sb_mode = 0, do_echo = 0; /* Various pieces for the telnet communication */ - char sb[1024] = {0}; + unsigned char sb[1024] = {0}; short sb_len = 0; /* Whether or not to show the MOTD intro */ @@ -481,7 +481,8 @@ int main(int argc, char ** argv) { /* This was a response to the NAWS command, meaning * that this should be a window size */ alarm(2); - terminal_width = sb[2]; + terminal_width = (sb[1] << 8) | sb[2]; + terminal_height = (sb[3] << 8) | sb[4]; done++; } break; @@ -606,7 +607,9 @@ int main(int argc, char ** argv) { signal(SIGPIPE, SIGPIPE_handler); /* Handle window changes */ - signal(SIGWINCH, SIGWINCH_handler); + if (!telnet) { + signal(SIGWINCH, SIGWINCH_handler); + } switch (ttype) { case 1: