diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 85d3539f74..b43188e820 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,8 @@ +2010-02-10 Pablo de la ConcepciĆ³n + + * lib/PandoraFMS/DataServer.pm: Validation of positiona parameters, check + if the parameters are defined and if they have valid values. + 2010-02-10 Sancho Lerena * bin/pandora_server: Better error management, avoiding to show Enterprise diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 90a6dfd6dd..9e6010822f 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -158,7 +158,7 @@ sub process_xml_data ($$$$$) { $data->{'interval'}, $data->{'os_version'}, $data->{'timezone_offset'}); # Timezone offset must be an integer beween -12 and +12 - if ($timezone_offset !~ /[-+]?[0-9,11,12]/) { + if (!defined($timezone_offset) || $timezone_offset !~ /[-+]?[0-9,11,12]/) { $timezone_offset = 0; # Default value } @@ -167,15 +167,20 @@ sub process_xml_data ($$$$$) { # Get GIS information my ($longitude, $latitude, $altitude) = ( $data->{'longitude'}, $data->{'latitude'}, $data->{'altitude'}); - # TODO: validate that the positional parameters and timezone are defined. if ($pa_config->{'activate_gis'}) { # Validate the GIS informtation + if (!defined($altitude) || $altitude !~ /[-+]?[0-9,11,12]/) { + $altitude = 0; # Default value + } - # If position data are not valid should be ignored - if ($longitude !~ /[-+]?[0-9]*\.?[0-9]+/ || $latitude !~ /[-+]?[0-9]*\.?[0-9]+/ || $altitude !~ /[-+]?[0-9]*\.?[0-9]+/) { + # If position data (at least longitude and latitde) are not valid should be ignored + if ($longitude !~ /[-+]?[0-9]*\.?[0-9]+/ || $latitude !~ /[-+]?[0-9]*\.?[0-9]+/ || !defined($longitude) || !defined($latitude)) { $valid_position_data = 0; + $longitude = ''; + $latitude = ''; + $altitude=''; } logger($pa_config, "Getting GIS Data=timezone_offset=$timezone_offset longitude=$longitude latitude=$latitude altitude=$altitude", 10);