Skip to content

Commit

Permalink
XQuartz: Add more sanity checking around string manipulation for xmodmap
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Huddleston <[email protected]>
  • Loading branch information
jeremyhu committed Jun 8, 2010
1 parent 0be81f9 commit 5e1ef1f
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions hw/xquartz/quartzKeyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
Expand Down

0 comments on commit 5e1ef1f

Please sign in to comment.