diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-11-27 13:24:30 +0100 |
|---|---|---|
| committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-11-27 13:24:30 +0100 |
| commit | 2917b8735f1d56211eac0ad1bf7a051a842abd76 (patch) | |
| tree | 7f28c844ae4699a77ede7d7cc18390697628845b /plugins/check_curl.c | |
| parent | 0378484a57f219fc0156e208bff5152ee8624837 (diff) | |
| download | monitoring-plugins-2917b8735f1d56211eac0ad1bf7a051a842abd76.tar.gz | |
check_curl: abort redir if location is not found
This commit changes the behaviour of check_curl slightly.
Previously when the redirection method was set to the old 'check_http'
style redirection and there was no "location" header in the original
answer 'check_curl' segfaulted.
Now, at least it dies properly with a message.
Diffstat (limited to 'plugins/check_curl.c')
| -rw-r--r-- | plugins/check_curl.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c index fc704171..4eaa5f1d 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c | |||
| @@ -672,6 +672,11 @@ redir_wrapper redir(curlhelp_write_curlbuf *header_buf, const check_curl_config | |||
| 672 | 672 | ||
| 673 | char *location = get_header_value(headers, nof_headers, "location"); | 673 | char *location = get_header_value(headers, nof_headers, "location"); |
| 674 | 674 | ||
| 675 | if (location == NULL) { | ||
| 676 | // location header not found | ||
| 677 | die(STATE_UNKNOWN, "HTTP UNKNOWN - could not find \"location\" header\n"); | ||
| 678 | } | ||
| 679 | |||
| 675 | if (verbose >= 2) { | 680 | if (verbose >= 2) { |
| 676 | printf(_("* Seen redirect location %s\n"), location); | 681 | printf(_("* Seen redirect location %s\n"), location); |
| 677 | } | 682 | } |
