Module: monitoring-plugins
 Branch: master
 Commit: 2917b8735f1d56211eac0ad1bf7a051a842abd76
 Author: Lorenz Kästle <[email protected]>
   Date: Thu Nov 27 13:24:30 2025 +0100
    URL: 
https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=2917b873

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.

---

 plugins/check_curl.c | 5 +++++
 1 file changed, 5 insertions(+)

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
 
        char *location = get_header_value(headers, nof_headers, "location");
 
+       if (location == NULL) {
+               // location header not found
+               die(STATE_UNKNOWN, "HTTP UNKNOWN - could not find \"location\" 
header\n");
+       }
+
        if (verbose >= 2) {
                printf(_("* Seen redirect location %s\n"), location);
        }

Reply via email to