[geocode-glib] server: Error out if IP address in query is invalid



commit 5358223feff13e519590b7e22dd0046f3d366cbd
Author: Satabdi Das <satabdidas gmail com>
Date:   Tue Jan 29 16:39:30 2013 +0530

    server: Error out if IP address in query is invalid
    
    If the server finds some IP address in the query string and it's an
    invalid IP address, it returns an error message.
    
    Earlier it was trying to guess the IP address of the client if the
    query string contained an invalid IP address.

 geocode-glib/geocode-ip-server/geoip-lookup.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/geocode-glib/geocode-ip-server/geoip-lookup.c b/geocode-glib/geocode-ip-server/geoip-lookup.c
index 9dc232e..8922ad3 100644
--- a/geocode-glib/geocode-ip-server/geoip-lookup.c
+++ b/geocode-glib/geocode-ip-server/geoip-lookup.c
@@ -340,7 +340,14 @@ get_ipaddress (void)
         char *value;
 
         value = get_ipaddress_from_query ();
-        if (!value) {
+        if (value) {
+                if (validate_ip_address (value) == FALSE) {
+                        print_error_in_json (INVALID_IP_ADDRESS_ERR, NULL);
+                        g_free (value);
+                        return NULL;
+                }
+        }
+        else {
                 value = get_client_ipaddress ();
                 if (!value) {
                         print_error_in_json (INVALID_IP_ADDRESS_ERR, NULL);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]