[network-manager-applet] editor: don't allow zero prefix for IP routes



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

    editor: don't allow zero prefix for IP routes

 src/connection-editor/ip4-routes-dialog.c |    2 +-
 src/connection-editor/ip6-routes-dialog.c |    8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/src/connection-editor/ip4-routes-dialog.c b/src/connection-editor/ip4-routes-dialog.c
index e93c3c9..9265446 100644
--- a/src/connection-editor/ip4-routes-dialog.c
+++ b/src/connection-editor/ip4-routes-dialog.c
@@ -426,7 +426,7 @@ cell_changed_cb (GtkEditable *editable,
                /* Is it a prefix? */
                if (!strchr (cell_text, '.')) {
                        tmp_prefix = strtol (cell_text, NULL, 10);
-                       if (*cell_text && !errno && tmp_prefix <= 32)
+                       if (*cell_text && !errno && tmp_prefix > 0 && tmp_prefix <= 32)
                                value_valid = TRUE;
                } else {
                        struct in_addr tmp_addr;
diff --git a/src/connection-editor/ip6-routes-dialog.c b/src/connection-editor/ip6-routes-dialog.c
index 9bad693..29108c7 100644
--- a/src/connection-editor/ip6-routes-dialog.c
+++ b/src/connection-editor/ip6-routes-dialog.c
@@ -138,7 +138,8 @@ validate (GtkWidget *dialog)
                g_free (dest);
 
                /* Prefix */
-               if (!get_one_int (model, &tree_iter, COL_PREFIX, 128, TRUE, &prefix))
+               if (   !get_one_int (model, &tree_iter, COL_PREFIX, 128, TRUE, &prefix)
+                   || prefix == 0)
                        goto done;
 
                /* Next hop (optional) */
@@ -379,7 +380,7 @@ cell_changed_cb (GtkEditable *editable,
 
                errno = 0;
                tmp_int = strtol (cell_text, NULL, 10);
-               if (!*cell_text || errno || tmp_int < 0 || tmp_int > 128)
+               if (!*cell_text || errno || tmp_int < 1 || tmp_int > 128)
                        value_valid = FALSE;
                else
                        value_valid = TRUE;
@@ -788,7 +789,8 @@ ip6_routes_dialog_update_setting (GtkWidget *dialog, NMSettingIPConfig *s_ip6)
                }
 
                /* Prefix */
-               if (!get_one_int (model, &tree_iter, COL_PREFIX, 128, TRUE, &prefix)) {
+               if (   !get_one_int (model, &tree_iter, COL_PREFIX, 128, TRUE, &prefix)
+                   || prefix == 0) {
                        g_warning ("%s: IPv6 prefix missing or invalid!", __func__);
                        g_free (dest);
                        goto next;


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