diff options
Diffstat (limited to 'plugins/check_curl.c')
| -rw-r--r-- | plugins/check_curl.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 0aff8b40..bd3f7dce 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c | |||
| @@ -761,7 +761,7 @@ redir_wrapper redir(curlhelp_write_curlbuf *header_buf, const check_curl_config | |||
| 761 | } | 761 | } |
| 762 | 762 | ||
| 763 | /* compose new path */ | 763 | /* compose new path */ |
| 764 | /* TODO: handle fragments and query part of URL */ | 764 | /* TODO: handle fragments of URL */ |
| 765 | char *new_url = (char *)calloc(1, DEFAULT_BUFFER_SIZE); | 765 | char *new_url = (char *)calloc(1, DEFAULT_BUFFER_SIZE); |
| 766 | if (uri.pathHead) { | 766 | if (uri.pathHead) { |
| 767 | for (UriPathSegmentA *pathSegment = uri.pathHead; pathSegment; | 767 | for (UriPathSegmentA *pathSegment = uri.pathHead; pathSegment; |
| @@ -772,6 +772,25 @@ redir_wrapper redir(curlhelp_write_curlbuf *header_buf, const check_curl_config | |||
| 772 | } | 772 | } |
| 773 | } | 773 | } |
| 774 | 774 | ||
| 775 | /* missing components have null,null in their UriTextRangeA | ||
| 776 | * add query parameters if they exist. | ||
| 777 | */ | ||
| 778 | if (uri.query.first && uri.query.afterLast){ | ||
| 779 | // Ensure we have space for '?' + query_str + '\0' ahead of time, instead of calling strncat twice | ||
| 780 | size_t current_len = strlen(new_url); | ||
| 781 | size_t remaining_space = DEFAULT_BUFFER_SIZE - current_len - 1; | ||
| 782 | |||
| 783 | const char* query_str = uri_string(uri.query, buf, DEFAULT_BUFFER_SIZE); | ||
| 784 | size_t query_str_len = strlen(query_str); | ||
| 785 | |||
| 786 | if (remaining_space >= query_str_len + 1) { | ||
| 787 | strcat(new_url, "?"); | ||
| 788 | strcat(new_url, query_str); | ||
| 789 | }else{ | ||
| 790 | die(STATE_UNKNOWN, _("HTTP UNKNOWN - No space to add query part of size %d to the buffer, buffer has remaining size %d"), query_str_len , current_len ); | ||
| 791 | } | ||
| 792 | } | ||
| 793 | |||
| 775 | if (working_state.serverPort == new_port && | 794 | if (working_state.serverPort == new_port && |
| 776 | !strncmp(working_state.server_address, new_host, MAX_IPV4_HOSTLENGTH) && | 795 | !strncmp(working_state.server_address, new_host, MAX_IPV4_HOSTLENGTH) && |
| 777 | (working_state.host_name && | 796 | (working_state.host_name && |
