From cae911bd51270f7d7fac7c06f3f1c625067a3b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20de=20la=20Concepci=C3=B3n=20Sanz?= Date: Wed, 10 Feb 2010 20:17:08 +0000 Subject: [PATCH] =?UTF-8?q?2010-02-10=20=20Pablo=20de=20la=20Concepci?= =?UTF-8?q?=C3=B3n=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lib/PandoraFMS/DataServer.pm: Validation of positiona parameters, check if the parameters are defined and if they have valid values. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2350 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 5 +++++ pandora_server/lib/PandoraFMS/DataServer.pm | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) 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);