diff options
-rw-r--r-- | nx-X11/programs/Xserver/xkb/ddxLoad.c | 21 | ||||
-rw-r--r-- | nx-X11/programs/Xserver/xkb/maprules.c | 3 |
2 files changed, 12 insertions, 12 deletions
diff --git a/nx-X11/programs/Xserver/xkb/ddxLoad.c b/nx-X11/programs/Xserver/xkb/ddxLoad.c index 306a3530f..bff69196f 100644 --- a/nx-X11/programs/Xserver/xkb/ddxLoad.c +++ b/nx-X11/programs/Xserver/xkb/ddxLoad.c @@ -404,15 +404,16 @@ FILE * file; &&(!isalpha(xkm_output_dir[0]) || xkm_output_dir[1]!=':') #endif ) { - if (strlen(XkbBaseDirectory)+strlen(xkm_output_dir) - +strlen(mapName)+6 <= PATH_MAX) - { - sprintf(buf,"%s/%s%s.xkm",XkbBaseDirectory, - xkm_output_dir,mapName); - } + if (snprintf(buf, PATH_MAX, "%s/%s%s.xkm", XkbBaseDirectory, + xkm_output_dir, mapName) >= PATH_MAX) + buf[0] = '\0'; + } + else + { + if (snprintf(buf, PATH_MAX, "%s%s.xkm", xkm_output_dir, mapName) + >= PATH_MAX) + buf[0] = '\0'; } - else if (strlen(xkm_output_dir)+strlen(mapName)+5 <= PATH_MAX) - sprintf(buf,"%s%s.xkm",xkm_output_dir,mapName); if (buf[0] != '\0') file= fopen(buf,"rb"); else file= NULL; @@ -505,9 +506,9 @@ XkbRF_RulesPtr rules; sprintf(buf,"rules/%s",rules_name); } else { - if (strlen(XkbBaseDirectory)+strlen(rules_name)+8 > PATH_MAX) + if (snprintf(buf, PATH_MAX, "%s/rules/%s", XkbBaseDirectory, rules_name) + >= PATH_MAX) return False; - sprintf(buf,"%s/rules/%s",XkbBaseDirectory,rules_name); } if ((file= fopen(buf,"r"))==NULL) return False; diff --git a/nx-X11/programs/Xserver/xkb/maprules.c b/nx-X11/programs/Xserver/xkb/maprules.c index af6c112fe..6bc7e4022 100644 --- a/nx-X11/programs/Xserver/xkb/maprules.c +++ b/nx-X11/programs/Xserver/xkb/maprules.c @@ -953,9 +953,8 @@ Bool ok; if ((!base)||(!rules)) return False; if (locale) { - if (strlen(base)+strlen(locale)+2 > PATH_MAX) + if (snprintf(buf, PATH_MAX, "%s-%s", base, locale) >= PATH_MAX) return False; - sprintf(buf,"%s-%s", base, locale); } else { if (strlen(base)+1 > PATH_MAX) |