blob: 8b9a0200e1481aabcb320e9c282ade478fc68a67 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
--- cgi/statuswml.c 2008/11/30 18:13:11 1.27
+++ cgi/statuswml.c 2009/06/19 04:30:26 1.28
@@ -67,6 +67,8 @@
void document_header(void);
void document_footer(void);
int process_cgivars(void);
+int validate_arguments(void);
+int is_valid_hostip(char *hostip);
int display_type=DISPLAY_INDEX;
int hostgroup_style=DISPLAY_HOSTGROUP_SUMMARY;
@@ -108,6 +110,13 @@
document_header();
+ /* validate arguments in URL */
+ result=validate_arguments();
+ if(result==ERROR){
+ document_footer();
+ return ERROR;
+ }
+
/* read the CGI configuration file */
result=read_cgi_config_file(get_cgi_config_location());
if(result==ERROR){
@@ -334,7 +343,25 @@
return error;
}
+int validate_arguments(void){
+ int result=OK;
+ if((strcmp(ping_address,"")) && !is_valid_hostip(ping_address)) {
+ printf("<p>Invalid host name/ip</p>\n");
+ result=ERROR;
+ }
+ if(strcmp(traceroute_address,"") && !is_valid_hostip(traceroute_address)){
+ printf("<p>Invalid host name/ip</p>\n");
+ result=ERROR;
+ }
+ return result;
+ }
+int is_valid_hostip(char *hostip) {
+ char *valid_domain_chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-";
+ if(strcmp(hostip,"") && strlen(hostip)==strspn(hostip,valid_domain_chars) && hostip[0] != '-' && hostip[strlen(hostip)-1] != '-')
+ return TRUE;
+ return FALSE;
+ }
/* main intro screen */
void display_index(void){
|