*
* The MIT License (MIT)
*
- * Copyright (C) 2017 Kevin Lamonte
+ * Copyright (C) 2019 Kevin Lamonte
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
/**
* TelnetInputStream works with TelnetSocket to perform the telnet protocol.
*/
-public final class TelnetInputStream extends InputStream
- implements SessionInfo {
+public class TelnetInputStream extends InputStream implements SessionInfo {
// ------------------------------------------------------------------------
// Constants --------------------------------------------------------------
if (subnegBuffer.get(i) == (byte)TELNET_IAC) {
i++;
}
- windowWidth = subnegBuffer.get(i) * 256;
+ int width = subnegBuffer.get(i);
+ if (width < 0) {
+ width += 256;
+ }
+ windowWidth = width * 256;
i++;
if (subnegBuffer.get(i) == (byte)TELNET_IAC) {
i++;
}
- windowWidth += subnegBuffer.get(i);
+ width = subnegBuffer.get(i);
+ windowWidth += width;
+ if (width < 0) {
+ windowWidth += 256;
+ }
i++;
if (subnegBuffer.get(i) == (byte)TELNET_IAC) {
i++;
}
- windowHeight = subnegBuffer.get(i) * 256;
+ int height = subnegBuffer.get(i);
+ if (height < 0) {
+ height += 256;
+ }
+ windowHeight = height * 256;
i++;
if (subnegBuffer.get(i) == (byte)TELNET_IAC) {
i++;
}
- windowHeight += subnegBuffer.get(i);
+ height = subnegBuffer.get(i);
+ windowHeight += height;
+ if (height < 0) {
+ windowHeight += 256;
+ }
}
break;