summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_http.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c
index f54f4ab8..4a3d692b 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -732,6 +732,22 @@ get_content_length (const char *headers)
732 return (content_length); 732 return (content_length);
733} 733}
734 734
735char *
736prepend_slash (char *path)
737{
738 char *newpath;
739
740 if (path[0] == '/')
741 return path;
742
743 if ((newpath = malloc (strlen(path) + 2)) == NULL)
744 die (STATE_UNKNOWN, _("HTTP UNKNOWN - Memory allocation error\n"));
745 newpath[0] = '/';
746 strcpy (newpath + 1, path);
747 free (path);
748 return newpath;
749}
750
735int 751int
736check_http (void) 752check_http (void)
737{ 753{
@@ -1112,11 +1128,14 @@ redir (char *pos, char *status_line)
1112 die (STATE_UNKNOWN, _("HTTP UNKNOWN - could not allocate url\n")); 1128 die (STATE_UNKNOWN, _("HTTP UNKNOWN - could not allocate url\n"));
1113 1129
1114 /* URI_HTTP, URI_HOST, URI_PORT, URI_PATH */ 1130 /* URI_HTTP, URI_HOST, URI_PORT, URI_PATH */
1115 if (sscanf (pos, HD1, type, addr, &i, url) == 4) 1131 if (sscanf (pos, HD1, type, addr, &i, url) == 4) {
1132 url = prepend_slash (url);
1116 use_ssl = server_type_check (type); 1133 use_ssl = server_type_check (type);
1134 }
1117 1135
1118 /* URI_HTTP URI_HOST URI_PATH */ 1136 /* URI_HTTP URI_HOST URI_PATH */
1119 else if (sscanf (pos, HD2, type, addr, url) == 3 ) { 1137 else if (sscanf (pos, HD2, type, addr, url) == 3 ) {
1138 url = prepend_slash (url);
1120 use_ssl = server_type_check (type); 1139 use_ssl = server_type_check (type);
1121 i = server_port_check (use_ssl); 1140 i = server_port_check (use_ssl);
1122 } 1141 }
@@ -1179,12 +1198,7 @@ redir (char *pos, char *status_line)
1179 server_address = strdup (addr); 1198 server_address = strdup (addr);
1180 1199
1181 free (server_url); 1200 free (server_url);
1182 if ((url[0] == '/')) 1201 server_url = url;
1183 server_url = strdup (url);
1184 else if (asprintf(&server_url, "/%s", url) == -1)
1185 die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate server_url%s\n"),
1186 display_html ? "</A>" : "");
1187 free(url);
1188 1202
1189 if ((server_port = i) > MAX_PORT) 1203 if ((server_port = i) > MAX_PORT)
1190 die (STATE_UNKNOWN, 1204 die (STATE_UNKNOWN,