Cap escape sequence parameters to prevent long loops.

Fixes #271 github issue.
This commit is contained in:
Keith Winstein
2012-05-15 23:46:09 -04:00
parent dee09fb8fc
commit 9791768705
2 changed files with 8 additions and 0 deletions
+5
View File
@@ -116,6 +116,11 @@ int Dispatcher::getparam( size_t N, int defaultval )
if ( parsed_params.size() > N ) { if ( parsed_params.size() > N ) {
ret = parsed_params[ N ]; ret = parsed_params[ N ];
} }
if ( ret > PARAM_MAX ) {
ret = defaultval;
}
if ( ret < 1 ) ret = defaultval; if ( ret < 1 ) ret = defaultval;
return ret; return ret;
+3
View File
@@ -77,6 +77,9 @@ namespace Terminal {
void parse_params( void ); void parse_params( void );
public: public:
static const int PARAM_MAX = 65535;
/* prevent evil escape sequences from causing long loops */
std::string terminal_to_host; /* this is the reply string */ std::string terminal_to_host; /* this is the reply string */
Dispatcher(); Dispatcher();