From 62223e8fbbccac5581da1464081662b44f8a6e03 Mon Sep 17 00:00:00 2001 From: Calvin Lee Date: Thu, 13 Jul 2017 07:47:21 -0700 Subject: Don't trust SNI names, fixes #1274 If an item doesn't have a well-formed name, it will not be added to the tray. --- swaybar/tray/sni.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'swaybar/tray/sni.c') diff --git a/swaybar/tray/sni.c b/swaybar/tray/sni.c index 0c46d5c0..d9a5ca80 100644 --- a/swaybar/tray/sni.c +++ b/swaybar/tray/sni.c @@ -413,6 +413,12 @@ static void get_unique_name(struct StatusNotifierItem *item) { } struct StatusNotifierItem *sni_create(const char *name) { + // Make sure `name` is well formed + if (!dbus_validate_bus_name(name, NULL)) { + sway_log(L_INFO, "Name (%s) is not a bus name. We cannot create an item.", name); + return NULL; + } + struct StatusNotifierItem *item = malloc(sizeof(struct StatusNotifierItem)); item->name = strdup(name); item->unique_name = NULL; -- cgit v1.2.3-54-g00ecf