[virt-tools-list] [PATCH virt-viewer v2 4/5] app: Check validity of hotkey value

Pavel Grunt pgrunt at redhat.com
Mon May 30 15:08:39 UTC 2016


Related: rhbz#1339572
---
 src/virt-viewer-app.c | 5 +++++
 tests/test-hotkeys.c  | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index d449f72..f8fba4c 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -2077,6 +2077,11 @@ virt_viewer_app_set_hotkeys(VirtViewerApp *self, const gchar *hotkeys_str)
         gtk_accelerator_parse(accel, &accel_key, &accel_mods);
         g_free(accel);
 
+        if (strlen(key + 1) != 0 && accel_key == 0 && accel_mods == 0) {
+            g_warning("Invalid value '%s' for key '%s'", key + 1, *hotkey);
+            continue;
+        }
+
         if (g_str_equal(*hotkey, "toggle-fullscreen")) {
             gtk_accel_map_change_entry("<virt-viewer>/view/toggle-fullscreen", accel_key, accel_mods, TRUE);
         } else if (g_str_equal(*hotkey, "release-cursor")) {
diff --git a/tests/test-hotkeys.c b/tests/test-hotkeys.c
index d3658f5..4a45216 100644
--- a/tests/test-hotkeys.c
+++ b/tests/test-hotkeys.c
@@ -96,6 +96,10 @@ test_hotkeys_bad(void)
             "toggle-fullscreen=A,unknown_command=B",
             G_LOG_LEVEL_WARNING,
             "Unknown hotkey command unknown_command"
+        },{
+            "secure-attention=value",
+            G_LOG_LEVEL_WARNING,
+            "Invalid value 'value' for key 'secure-attention'"
         },
     };
 
-- 
2.8.3




More information about the virt-tools-list mailing list