analyzer/protocol/ident: fix buffer overflow in ParsePort()

The given buffer is not null-terminated; the method must obey the
"end_of_line" pointer.
This commit is contained in:
Max Kellermann 2020-02-10 15:30:12 +01:00
parent f849571910
commit 9b2709ca18

View file

@ -215,7 +215,7 @@ const char* Ident_Analyzer::ParsePort(const char* line, const char* end_of_line,
int n = 0;
line = skip_whitespace(line, end_of_line);
if ( ! isdigit(*line) )
if ( line >= end_of_line || ! isdigit(*line) )
return nullptr;
const char* l = line;
@ -225,7 +225,7 @@ const char* Ident_Analyzer::ParsePort(const char* line, const char* end_of_line,
n = n * 10 + (*line - '0');
++line;
}
while ( isdigit(*line) );
while ( line < end_of_line && isdigit(*line) );
line = skip_whitespace(line, end_of_line);