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

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

 



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

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list



[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux