From 465d686a86fa2c1eacf2bca5390399ca88a94560 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Wed, 1 Nov 2023 10:49:03 +0100 Subject: src/keyboard-x11.c: Skip AccountsService operations for all prefixed users --- src/keyboard-x11.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/keyboard-x11.c b/src/keyboard-x11.c index 141a23ee..c1b256a2 100644 --- a/src/keyboard-x11.c +++ b/src/keyboard-x11.c @@ -139,9 +139,9 @@ static void getAccountsService(Keyboard *pKeyboard, ActUser *pUser) g_variant_get (pUser, "(s)", &pKeyboard->pPrivate->sUser); } - gboolean bGuest = g_str_equal (pKeyboard->pPrivate->sUser, "*guest"); + gboolean bPrefix = g_str_has_prefix (pKeyboard->pPrivate->sUser, "*"); - if (bGuest) + if (bPrefix) { if (pKeyboard->pPrivate->lLayoutRec) { -- cgit v1.2.3 From 76e4d65da8d64961654bad0ea8b4f094dd5608ad Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Wed, 1 Nov 2023 11:11:01 +0100 Subject: Check if layout array is null before iterating it --- src/keyboard-lomiri.c | 36 ++++++++++++++++++++---------------- src/keyboard-x11.c | 38 +++++++++++++++++++++----------------- 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/src/keyboard-lomiri.c b/src/keyboard-lomiri.c index e5e0f623..1455b95e 100644 --- a/src/keyboard-lomiri.c +++ b/src/keyboard-lomiri.c @@ -431,7 +431,6 @@ static void keyboard_init(Keyboard *self) } } - guint nLayouts = g_strv_length(lLayouts); guint nVariants = 0; if (lVariants != NULL) @@ -439,34 +438,39 @@ static void keyboard_init(Keyboard *self) g_strv_length(lVariants); } - for (guint nLayout = 0; nLayout < nLayouts; nLayout++) + if (lLayouts != NULL) { - gchar *sId = NULL; + guint nLayouts = g_strv_length(lLayouts); - if (nVariants > nLayout) + for (guint nLayout = 0; nLayout < nLayouts; nLayout++) { - guint nVariant = strlen(lVariants[nLayout]); + gchar *sId = NULL; - if (nVariants == nLayouts && nVariant > 0) + if (nVariants > nLayout) { - sId = g_strconcat(lLayouts[nLayout], "+", lVariants[nLayout], NULL); + guint nVariant = strlen(lVariants[nLayout]); + + if (nVariants == nLayouts && nVariant > 0) + { + sId = g_strconcat(lLayouts[nLayout], "+", lVariants[nLayout], NULL); + } + else + { + sId = g_strdup(lLayouts[nLayout]); + } } else { sId = g_strdup(lLayouts[nLayout]); } - } - else - { - sId = g_strdup(lLayouts[nLayout]); - } - self->pPrivate->lLayoutRec = g_slist_append(self->pPrivate->lLayoutRec, sId); - } + self->pPrivate->lLayoutRec = g_slist_append(self->pPrivate->lLayoutRec, sId); + } - self->pPrivate->nLayout = 0; + self->pPrivate->nLayout = 0; - g_strfreev(lLayouts); + g_strfreev(lLayouts); + } if (lVariants != NULL) { diff --git a/src/keyboard-x11.c b/src/keyboard-x11.c index c1b256a2..fa945f01 100644 --- a/src/keyboard-x11.c +++ b/src/keyboard-x11.c @@ -702,7 +702,6 @@ static void keyboard_init(Keyboard *self) } } - guint nLayouts = g_strv_length(lLayouts); guint nVariants = 0; if (lVariants != NULL) @@ -710,35 +709,40 @@ static void keyboard_init(Keyboard *self) nVariants = g_strv_length(lVariants); } - for (guint nLayout = 0; nLayout < nLayouts; nLayout++) + if (lLayouts != NULL) { - gchar *sId = NULL; + guint nLayouts = g_strv_length(lLayouts); - if (nVariants > nLayout) + for (guint nLayout = 0; nLayout < nLayouts; nLayout++) { - guint nVariant = strlen(lVariants[nLayout]); + gchar *sId = NULL; - if (nVariants == nLayouts && nVariant > 0) + if (nVariants > nLayout) { - sId = g_strconcat(lLayouts[nLayout], "+", lVariants[nLayout], NULL); + guint nVariant = strlen(lVariants[nLayout]); + + if (nVariants == nLayouts && nVariant > 0) + { + sId = g_strconcat(lLayouts[nLayout], "+", lVariants[nLayout], NULL); + } + else + { + sId = g_strdup(lLayouts[nLayout]); + } } else { sId = g_strdup(lLayouts[nLayout]); } - } - else - { - sId = g_strdup(lLayouts[nLayout]); - } - self->pPrivate->lLayoutRec = g_slist_append(self->pPrivate->lLayoutRec, sId); - self->pPrivate->sSystemLayout = g_strdup(sId); - } + self->pPrivate->lLayoutRec = g_slist_append(self->pPrivate->lLayoutRec, sId); + self->pPrivate->sSystemLayout = g_strdup(sId); + } - self->pPrivate->nLayout = 0; + self->pPrivate->nLayout = 0; - g_strfreev(lLayouts); + g_strfreev(lLayouts); + } if (lVariants != NULL) { -- cgit v1.2.3