summaryrefslogtreecommitdiff
path: root/config/hal.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2008-08-01 15:52:07 +0930
committerPeter Hutterer <peter.hutterer@who-t.net>2008-08-04 15:15:16 +0930
commit3c6a9c531f673b7a0cb9ca01860b4dbe79686363 (patch)
tree00ae7d4fdea12abd74a93f4ad9f9e59cdfb0a209 /config/hal.c
parent92c51b183c2ff06361dad7f918daed6577ba4935 (diff)
config: protect against potential out-of-bounds indexing.
Diffstat (limited to 'config/hal.c')
-rw-r--r--config/hal.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/config/hal.c b/config/hal.c
index a954af95f..3e0ff0895 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -260,7 +260,7 @@ device_added(LibHalContext *hal_ctx, const char *udi)
* Since we can't predict the order in which the keys
* arrive, we need to store them.
*/
- if ((tmp = strcasestr(psi_key, "xkb")))
+ if ((tmp = strcasestr(psi_key, "xkb")) && strlen(tmp) >= 4)
{
if (!strcasecmp(&tmp[3], "layout"))
{
@@ -298,6 +298,7 @@ device_added(LibHalContext *hal_ctx, const char *udi)
{
/* server 1.4 had xkb_options as strlist. */
if ((tmp = strcasestr(psi_key, "xkb")) &&
+ (strlen(tmp) >= 4) &&
(!strcasecmp(&tmp[3], "options")) &&
(tmp_val = get_prop_string_array(hal_ctx, udi, psi_key)))
{
@@ -312,7 +313,7 @@ device_added(LibHalContext *hal_ctx, const char *udi)
/* only support strings for all values */
tmp_val = get_prop_string(hal_ctx, udi, psi_key);
- if (tmp_val){
+ if (tmp_val && strlen(psi_key) >= sizeof(LIBHAL_XKB_PROP_KEY)) {
tmp = &psi_key[sizeof(LIBHAL_XKB_PROP_KEY) - 1];
@@ -342,7 +343,7 @@ device_added(LibHalContext *hal_ctx, const char *udi)
{
/* server 1.4 had xkb options as strlist */
tmp_val = get_prop_string_array(hal_ctx, udi, psi_key);
- if (tmp_val)
+ if (tmp_val && strlen(psi_key) >= sizeof(LIBHAL_XKB_PROP_KEY))
{
tmp = &psi_key[sizeof(LIBHAL_XKB_PROP_KEY) - 1];
if (!strcasecmp(tmp, ".options") && (!xkb_opts.options))