diff options
author | Sven Nierlein <sven@nierlein.de> | 2021-03-11 13:33:16 +0100 |
---|---|---|
committer | Sven Nierlein <sven@nierlein.de> | 2021-03-11 13:33:16 +0100 |
commit | 5cfc93d995cfd5cc7d1a469f3c1276c4884da2a2 (patch) | |
tree | ee6ce79d0a5807dd8eb60c4bfa13cccc5ae0ba0c /plugins/check_curl.c | |
parent | 05d7f70d4553e19ea5eb27ec5c97098f014550df (diff) | |
download | monitoring-plugins-5cfc93d995cfd5cc7d1a469f3c1276c4884da2a2.tar.gz |
fix check_curl crash if http header contains leading spaces
check_curl crashes when a (broken) http server returns invalid http header with
leading spaces or double colons. This PR adds a fix and a test case for this.
Signed-off-by: Sven Nierlein <sven@nierlein.de>
Diffstat (limited to 'plugins/check_curl.c')
-rw-r--r-- | plugins/check_curl.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 2d69b310..ef96218c 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c | |||
@@ -2037,7 +2037,7 @@ get_header_value (const struct phr_header* headers, const size_t nof_headers, co | |||
2037 | { | 2037 | { |
2038 | int i; | 2038 | int i; |
2039 | for( i = 0; i < nof_headers; i++ ) { | 2039 | for( i = 0; i < nof_headers; i++ ) { |
2040 | if( strncasecmp( header, headers[i].name, max( headers[i].name_len, 4 ) ) == 0 ) { | 2040 | if(headers[i].name != NULL && strncasecmp( header, headers[i].name, max( headers[i].name_len, 4 ) ) == 0 ) { |
2041 | return strndup( headers[i].value, headers[i].value_len ); | 2041 | return strndup( headers[i].value, headers[i].value_len ); |
2042 | } | 2042 | } |
2043 | } | 2043 | } |