Skip to content

Commit

Permalink
Cap escape sequence parameters to prevent long loops.
Browse files Browse the repository at this point in the history
Fixes #271 github issue.
  • Loading branch information
keithw committed May 16, 2012
1 parent dee09fb commit 9791768
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/terminal/terminaldispatcher.cc
Expand Up @@ -116,6 +116,11 @@ int Dispatcher::getparam( size_t N, int defaultval )
if ( parsed_params.size() > N ) {
ret = parsed_params[ N ];
}

if ( ret > PARAM_MAX ) {
ret = defaultval;
}

if ( ret < 1 ) ret = defaultval;

return ret;
Expand Down
3 changes: 3 additions & 0 deletions src/terminal/terminaldispatcher.h
Expand Up @@ -77,6 +77,9 @@ namespace Terminal {
void parse_params( void );

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 */

Dispatcher();
Expand Down

0 comments on commit 9791768

Please sign in to comment.