[network-manager-applet/jk/editor-error-bg-color-bgo660915: 2/3] editor: accept NULL in parse_netmask



commit a1348e4c0d839b1c89de286940c28dc28252f9eb
Author: Jiří Klimeš <jklimes redhat com>
Date:   Wed Mar 4 14:19:24 2015 +0100

    editor: accept NULL in parse_netmask

 src/connection-editor/page-ip4.c |    7 +++++--
 src/connection-editor/page-ip6.c |    4 ++--
 2 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/src/connection-editor/page-ip4.c b/src/connection-editor/page-ip4.c
index 6a8fe06..f5d0109 100644
--- a/src/connection-editor/page-ip4.c
+++ b/src/connection-editor/page-ip4.c
@@ -662,6 +662,9 @@ parse_netmask (const char *str, guint32 *prefix)
        struct in_addr tmp_addr;
        glong tmp_prefix;
 
+       if (!str || !*str)
+               return FALSE;
+
        errno = 0;
 
        /* Is it a prefix? */
@@ -899,7 +902,7 @@ cell_error_data_func (GtkTreeViewColumn *tree_column,
        if (col == COL_ADDRESS)
                invalid = !value || !*value || !nm_utils_ipaddr_valid (AF_INET, value);
        else if (col == COL_PREFIX)
-               invalid = !value || !*value || !parse_netmask (value, &prefix);
+               invalid = !parse_netmask (value, &prefix);
        else if (col == COL_GATEWAY)
                invalid = value && *value && !nm_utils_ipaddr_valid (AF_INET, value);
        else
@@ -1140,7 +1143,7 @@ ui_to_setting (CEPageIP4 *self)
                        goto out;
                }
 
-               if (!netmask || !parse_netmask (netmask, &prefix)) {
+               if (!parse_netmask (netmask, &prefix)) {
                        g_warning ("%s: IPv4 prefix '%s' missing or invalid!",
                                   __func__, netmask ? netmask : "<none>");
                        g_free (addr);
diff --git a/src/connection-editor/page-ip6.c b/src/connection-editor/page-ip6.c
index d08f229..915faf6 100644
--- a/src/connection-editor/page-ip6.c
+++ b/src/connection-editor/page-ip6.c
@@ -461,7 +461,7 @@ is_prefix_valid (const char *prefix_str, guint32 *out_prefix)
        guint32 prefix;
        char *end;
 
-       if (!prefix_str)
+       if (!prefix_str || !*prefix_str)
                return FALSE;
 
        prefix = strtoul (prefix_str, &end, 10);
@@ -902,7 +902,7 @@ cell_error_data_func (GtkTreeViewColumn *tree_column,
        if (col == COL_ADDRESS)
                invalid = !value || !*value || !nm_utils_ipaddr_valid (AF_INET6, value);
        else if (col == COL_PREFIX)
-               invalid = !value || !*value || !is_prefix_valid (value, NULL);
+               invalid = !is_prefix_valid (value, NULL);
        else if (col == COL_GATEWAY)
                invalid = value && *value && !nm_utils_ipaddr_valid (AF_INET6, value);
        else


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