diff options
author | Jeremy Huddleston <jeremyhu@apple.com> | 2010-06-08 13:01:10 -0700 |
---|---|---|
committer | Jeremy Huddleston <jeremyhu@apple.com> | 2010-06-08 13:01:10 -0700 |
commit | 5e1ef1f4dde4615498c1c5e7a4e422c3b3432fe8 (patch) | |
tree | 3fac0abcbc1e2d1f34ea625fc67e2b4aa5bf72cf /hw | |
parent | 0be81f9a163f2838448caee41b2dda274d73391a (diff) |
XQuartz: Add more sanity checking around string manipulation for xmodmap
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/xquartz/quartzKeyboard.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c index 745333f03..75cf23ff4 100644 --- a/hw/xquartz/quartzKeyboard.c +++ b/hw/xquartz/quartzKeyboard.c @@ -427,20 +427,28 @@ void DarwinKeyboardReloadHandler(void) { } } pthread_mutex_unlock(&keyInfo_mutex); - /* Check for system .Xmodmap */ + /* Modify with xmodmap */ if (access(xmodmap, F_OK) == 0) { + /* Check for system .Xmodmap */ if (access(sysmodmap, F_OK) == 0) { - snprintf (cmd, sizeof(cmd), "%s %s", xmodmap, sysmodmap); - X11ApplicationLaunchClient(cmd); + if(snprintf (cmd, sizeof(cmd), "%s %s", xmodmap, sysmodmap) < sizeof(cmd)) { + X11ApplicationLaunchClient(cmd); + } else { + ErrorF("X11.app: Unable to create / execute xmodmap command line"); + } } - } - - /* Check for user's local .Xmodmap */ - if (homedir != NULL) { - snprintf (usermodmap, sizeof(usermodmap), "%s/.Xmodmap", homedir); - if (access(usermodmap, F_OK) == 0) { - snprintf (cmd, sizeof(cmd), "%s %s", xmodmap, usermodmap); - X11ApplicationLaunchClient(cmd); + + /* Check for user's local .Xmodmap */ + if ((homedir != NULL) && (snprintf (usermodmap, sizeof(usermodmap), "%s/.Xmodmap", homedir) < sizeof(usermodmap))) { + if (access(usermodmap, F_OK) == 0) { + if(snprintf (cmd, sizeof(cmd), "%s %s", xmodmap, usermodmap) < sizeof(cmd)) { + X11ApplicationLaunchClient(cmd); + } else { + ErrorF("X11.app: Unable to create / execute xmodmap command line"); + } + } + } else { + ErrorF("X11.app: Unable to determine path to user's .Xmodmap"); } } } |