diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_http.c | 4 | ||||
-rw-r--r-- | plugins/utils.c | 31 |
2 files changed, 26 insertions, 9 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c index 856acde..d13050a 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -187,7 +187,7 @@ struct timeval tv; | |||
187 | #define URI_PATH "%[/a-zA-Z0-9._-=@,]" | 187 | #define URI_PATH "%[/a-zA-Z0-9._-=@,]" |
188 | 188 | ||
189 | enum { | 189 | enum { |
190 | MAX_IPV4_HOSTLENGTH = 64, | 190 | MAX_IPV4_HOSTLENGTH = 255, |
191 | HTTP_PORT = 80, | 191 | HTTP_PORT = 80, |
192 | HTTPS_PORT = 443 | 192 | HTTPS_PORT = 443 |
193 | }; | 193 | }; |
@@ -734,7 +734,7 @@ check_http (void) | |||
734 | asprintf (&orig_url, "%s", server_url); | 734 | asprintf (&orig_url, "%s", server_url); |
735 | pos = header; | 735 | pos = header; |
736 | while (pos) { | 736 | while (pos) { |
737 | server_address = realloc (server_address, MAX_IPV4_HOSTLENGTH); | 737 | server_address = realloc (server_address, MAX_IPV4_HOSTLENGTH + 1); |
738 | if (server_address == NULL) | 738 | if (server_address == NULL) |
739 | terminate (STATE_UNKNOWN, | 739 | terminate (STATE_UNKNOWN, |
740 | "HTTP UNKNOWN: could not allocate server_address"); | 740 | "HTTP UNKNOWN: could not allocate server_address"); |
diff --git a/plugins/utils.c b/plugins/utils.c index aaa9fe5..d06978f 100644 --- a/plugins/utils.c +++ b/plugins/utils.c | |||
@@ -192,24 +192,41 @@ is_dotted_quad (char *address) | |||
192 | } | 192 | } |
193 | 193 | ||
194 | /* from RFC-1035 | 194 | /* from RFC-1035 |
195 | * | 195 | * |
196 | * The labels must follow the rules for ARPANET host names. They must | 196 | * The labels must follow the rules for ARPANET host names. They must |
197 | * start with a letter, end with a letter or digit, and have as interior | 197 | * start with a letter, end with a letter or digit, and have as interior |
198 | * characters only letters, digits, and hyphen. There are also some | 198 | * characters only letters, digits, and hyphen. There are also some |
199 | * restrictions on the length. Labels must be 63 characters or less. */ | 199 | * restrictions on the length. Labels must be 63 characters or less. |
200 | * | ||
201 | * Then RFC-1123: | ||
202 | * | ||
203 | * 2.1 Host Names and Numbers | ||
204 | * | ||
205 | * The syntax of a legal Internet host name was specified in RFC-952 | ||
206 | * [DNS:4]. One aspect of host name syntax is hereby changed: the | ||
207 | * restriction on the first character is relaxed to allow either a | ||
208 | * letter or a digit. Host software MUST support this more liberal | ||
209 | * syntax. | ||
210 | * | ||
211 | * Host software MUST handle host names of up to 63 characters and | ||
212 | * SHOULD handle host names of up to 255 characters. | ||
213 | */ | ||
200 | 214 | ||
201 | int | 215 | int |
202 | is_hostname (char *s1) | 216 | is_hostname (char *s1) |
203 | { | 217 | { |
204 | if (!s1 || strlen (s1) > 63) { | 218 | if (!s1 || strlen (s1) > 255) { |
205 | return FALSE; | 219 | return FALSE; |
206 | } | 220 | } |
221 | /* if s1 contains anything but ALPHA, NUM, dash, or period*/ | ||
207 | if (strcspn (s1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWVXYZ0123456789-.") != 0) { | 222 | if (strcspn (s1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWVXYZ0123456789-.") != 0) { |
208 | return FALSE; | 223 | return FALSE; |
209 | } | 224 | } |
210 | if (strspn (s1, "0123456789-.") == 1) { | 225 | /* or if s1 begins with dash or period */ |
226 | if (strspn (s1, "-.") == 1) { | ||
211 | return FALSE; | 227 | return FALSE; |
212 | } | 228 | } |
229 | /* '..' and '.-' are not legal either */ | ||
213 | while ((s1 = index (s1, '.'))) { | 230 | while ((s1 = index (s1, '.'))) { |
214 | s1++; | 231 | s1++; |
215 | if (strspn (s1, "0123456789-.") == 1) { | 232 | if (strspn (s1, "0123456789-.") == 1) { |