Index: Font.c =================================================================== RCS file: /cvsroot/xsrc/external/mit/libX11/dist/src/Font.c,v retrieving revision 1.7 retrieving revision 1.8 diff -p -u -r1.7 -r1.8 --- Font.c 31 Jul 2020 19:29:52 -0000 1.7 +++ Font.c 19 May 2021 08:20:08 -0000 1.8 @@ -102,6 +102,8 @@ XFontStruct *XLoadQueryFont( XF86BigfontCodes *extcodes = _XF86BigfontCodes(dpy); #endif + if (strlen(name) >= USHRT_MAX) + return NULL; if (_XF86LoadQueryLocaleFont(dpy, name, &font_result, (Font *)0)) return font_result; LockDisplay(dpy); @@ -663,7 +665,7 @@ int _XF86LoadQueryLocaleFont( if (!name) return 0; l = (int) strlen(name); - if (l < 2 || name[l - 1] != '*' || name[l - 2] != '-') + if (l < 2 || name[l - 1] != '*' || name[l - 2] != '-' || l >= USHRT_MAX) return 0; charset = NULL; /* next three lines stolen from _XkbGetCharset() */ Index: FontInfo.c =================================================================== RCS file: /cvsroot/xsrc/external/mit/libX11/dist/src/FontInfo.c,v retrieving revision 1.1.1.9 retrieving revision 1.1.1.10 diff -p -u -r1.1.1.9 -r1.1.1.10 --- FontInfo.c 31 Jul 2020 19:19:42 -0000 1.1.1.9 +++ FontInfo.c 19 May 2021 08:19:11 -0000 1.1.1.10 @@ -58,6 +58,9 @@ XFontStruct **info) /* RETURN */ register xListFontsReq *req; int j; + if (strlen(pattern) >= USHRT_MAX) + return NULL; + LockDisplay(dpy); GetReq(ListFontsWithInfo, req); req->maxNames = maxNames; Index: FontNames.c =================================================================== RCS file: /cvsroot/xsrc/external/mit/libX11/dist/src/FontNames.c,v retrieving revision 1.9 retrieving revision 1.10 diff -p -u -r1.9 -r1.10 --- FontNames.c 31 Jul 2020 19:29:52 -0000 1.9 +++ FontNames.c 19 May 2021 08:20:08 -0000 1.10 @@ -51,6 +51,9 @@ int *actualCount) /* RETURN */ register xListFontsReq *req; unsigned long rlen = 0; + if (strlen(pattern) >= USHRT_MAX) + return NULL; + LockDisplay(dpy); GetReq(ListFonts, req); req->maxNames = maxNames; Index: GetColor.c =================================================================== RCS file: /cvsroot/xsrc/external/mit/libX11/dist/src/GetColor.c,v retrieving revision 1.1.1.4 retrieving revision 1.1.1.5 diff -p -u -r1.1.1.4 -r1.1.1.5 --- GetColor.c 31 Jul 2020 19:19:42 -0000 1.1.1.4 +++ GetColor.c 19 May 2021 08:19:11 -0000 1.1.1.5 @@ -27,6 +27,7 @@ in this Software without prior written a #ifdef HAVE_CONFIG_H #include #endif +#include #include #include "Xlibint.h" #include "Xcmsint.h" @@ -48,6 +49,9 @@ XColor *exact_def) /* RETURN */ XcmsColor cmsColor_exact; Status ret; + if (strlen(colorname) >= USHRT_MAX) + return (0); + #ifdef XCMS /* * Let's Attempt to use Xcms and i18n approach to Parse Color Index: LoadFont.c =================================================================== RCS file: /cvsroot/xsrc/external/mit/libX11/dist/src/LoadFont.c,v retrieving revision 1.1.1.4 retrieving revision 1.1.1.5 diff -p -u -r1.1.1.4 -r1.1.1.5 --- LoadFont.c 31 Jul 2020 19:19:43 -0000 1.1.1.4 +++ LoadFont.c 19 May 2021 08:19:12 -0000 1.1.1.5 @@ -27,6 +27,7 @@ in this Software without prior written a #ifdef HAVE_CONFIG_H #include #endif +#include #include "Xlibint.h" Font @@ -38,6 +39,9 @@ XLoadFont ( Font fid; register xOpenFontReq *req; + if (strlen(name) >= USHRT_MAX) + return (0); + if (_XF86LoadQueryLocaleFont(dpy, name, (XFontStruct **)0, &fid)) return fid; Index: LookupCol.c =================================================================== RCS file: /cvsroot/xsrc/external/mit/libX11/dist/src/LookupCol.c,v retrieving revision 1.1.1.4 retrieving revision 1.1.1.5 diff -p -u -r1.1.1.4 -r1.1.1.5 --- LookupCol.c 31 Jul 2020 19:19:43 -0000 1.1.1.4 +++ LookupCol.c 19 May 2021 08:19:11 -0000 1.1.1.5 @@ -27,6 +27,7 @@ in this Software without prior written a #ifdef HAVE_CONFIG_H #include #endif +#include #include #include "Xlibint.h" #include "Xcmsint.h" @@ -46,6 +47,9 @@ XLookupColor ( XcmsCCC ccc; XcmsColor cmsColor_exact; + n = (int) strlen (spec); + if (n >= USHRT_MAX) + return 0; #ifdef XCMS /* * Let's Attempt to use Xcms and i18n approach to Parse Color @@ -77,8 +81,6 @@ XLookupColor ( * Xcms and i18n methods failed, so lets pass it to the server * for parsing. */ - - n = (int) strlen (spec); LockDisplay(dpy); GetReq (LookupColor, req); req->cmap = cmap; Index: ParseCol.c =================================================================== RCS file: /cvsroot/xsrc/external/mit/libX11/dist/src/ParseCol.c,v retrieving revision 1.1.1.4 retrieving revision 1.1.1.5 diff -p -u -r1.1.1.4 -r1.1.1.5 --- ParseCol.c 31 Jul 2020 19:19:43 -0000 1.1.1.4 +++ ParseCol.c 19 May 2021 08:19:11 -0000 1.1.1.5 @@ -27,6 +27,7 @@ in this Software without prior written a #ifdef HAVE_CONFIG_H #include #endif +#include #include #include "Xlibint.h" #include "Xcmsint.h" @@ -47,6 +48,8 @@ XParseColor ( if (!spec) return(0); n = (int) strlen (spec); + if (n >= USHRT_MAX) + return(0); if (*spec == '#') { /* * RGB Index: QuExt.c =================================================================== RCS file: /cvsroot/xsrc/external/mit/libX11/dist/src/QuExt.c,v retrieving revision 1.1.1.5 retrieving revision 1.1.1.6 diff -p -u -r1.1.1.5 -r1.1.1.6 --- QuExt.c 31 Jul 2020 19:19:43 -0000 1.1.1.5 +++ QuExt.c 19 May 2021 08:19:11 -0000 1.1.1.6 @@ -27,6 +27,8 @@ in this Software without prior written a #ifdef HAVE_CONFIG_H #include #endif +#include +#include #include "Xlibint.h" Bool @@ -40,6 +42,9 @@ XQueryExtension( xQueryExtensionReply rep; register xQueryExtensionReq *req; + if (strlen(name) >= USHRT_MAX) + return false; + LockDisplay(dpy); GetReq(QueryExtension, req); req->nbytes = name ? (CARD16) strlen(name) : 0; Index: SetFPath.c =================================================================== RCS file: /cvsroot/xsrc/external/mit/libX11/dist/src/SetFPath.c,v retrieving revision 1.1.1.5 retrieving revision 1.2 diff -p -u -r1.1.1.5 -r1.2 --- SetFPath.c 31 Jul 2020 19:19:44 -0000 1.1.1.5 +++ SetFPath.c 19 May 2021 08:28:15 -0000 1.2 @@ -27,6 +27,7 @@ in this Software without prior written a #ifdef HAVE_CONFIG_H #include #endif +#include #include "Xlibint.h" #define safestrlen(s) ((s) ? strlen(s) : 0) @@ -49,6 +50,11 @@ XSetFontPath ( req->nFonts = ndirs; for (i = 0; i < ndirs; i++) { n = (int) ((size_t) n + (safestrlen (directories[i]) + 1)); + if (n >= USHRT_MAX) { + UnlockDisplay(dpy); + SyncHandle(); + return 0; + } } nbytes = (n + 3) & ~3; req->length += nbytes >> 2; Index: SetHints.c =================================================================== RCS file: /cvsroot/xsrc/external/mit/libX11/dist/src/SetHints.c,v retrieving revision 1.1.1.8 retrieving revision 1.1.1.9 diff -p -u -r1.1.1.8 -r1.1.1.9 --- SetHints.c 31 Jul 2020 19:19:44 -0000 1.1.1.8 +++ SetHints.c 19 May 2021 08:19:11 -0000 1.1.1.9 @@ -49,6 +49,7 @@ SOFTWARE. #ifdef HAVE_CONFIG_H #include #endif +#include #include #include #include "Xatomtype.h" @@ -214,6 +215,8 @@ XSetCommand ( register char *buf, *bp; for (i = 0, nbytes = 0; i < argc; i++) { nbytes += safestrlen(argv[i]) + 1; + if (nbytes >= USHRT_MAX) + return 1; } if ((bp = buf = Xmalloc(nbytes))) { /* copy arguments into single buffer */ @@ -256,6 +259,8 @@ XSetStandardProperties ( if (name != NULL) XStoreName (dpy, w, name); + if (safestrlen(icon_string) >= USHRT_MAX) + return 1; if (icon_string != NULL) { XChangeProperty (dpy, w, XA_WM_ICON_NAME, XA_STRING, 8, PropModeReplace, @@ -298,6 +303,8 @@ XSetClassHint( len_nm = safestrlen(classhint->res_name); len_cl = safestrlen(classhint->res_class); + if (len_nm + len_cl >= USHRT_MAX) + return 1; if ((class_string = s = Xmalloc(len_nm + len_cl + 2))) { if (len_nm) { strcpy(s, classhint->res_name); Index: StNColor.c =================================================================== RCS file: /cvsroot/xsrc/external/mit/libX11/dist/src/StNColor.c,v retrieving revision 1.1.1.3 retrieving revision 1.1.1.4 diff -p -u -r1.1.1.3 -r1.1.1.4 --- StNColor.c 31 Jul 2020 19:19:44 -0000 1.1.1.3 +++ StNColor.c 19 May 2021 08:19:11 -0000 1.1.1.4 @@ -27,6 +27,7 @@ in this Software without prior written a #ifdef HAVE_CONFIG_H #include #endif +#include #include #include "Xlibint.h" #include "Xcmsint.h" @@ -46,6 +47,8 @@ int flags) /* DoRed, DoGreen, DoBlue */ XcmsColor cmsColor_exact; XColor scr_def; + if (strlen(name) >= USHRT_MAX) + return 0; #ifdef XCMS /* * Let's Attempt to use Xcms approach to Parse Color Index: StName.c =================================================================== RCS file: /cvsroot/xsrc/external/mit/libX11/dist/src/StName.c,v retrieving revision 1.1.1.5 retrieving revision 1.1.1.6 diff -p -u -r1.1.1.5 -r1.1.1.6 --- StName.c 31 Jul 2020 19:19:44 -0000 1.1.1.5 +++ StName.c 19 May 2021 08:19:11 -0000 1.1.1.6 @@ -27,6 +27,7 @@ in this Software without prior written a #ifdef HAVE_CONFIG_H #include #endif +#include #include #include @@ -36,7 +37,9 @@ XStoreName ( Window w, _Xconst char *name) { - return XChangeProperty(dpy, w, XA_WM_NAME, XA_STRING, + if (strlen(name) >= USHRT_MAX) + return 0; + return XChangeProperty(dpy, w, XA_WM_NAME, XA_STRING, /* */ 8, PropModeReplace, (_Xconst unsigned char *)name, name ? (int) strlen(name) : 0); } @@ -47,6 +50,8 @@ XSetIconName ( Window w, _Xconst char *icon_name) { + if (strlen(icon_name) >= USHRT_MAX) + return 0; return XChangeProperty(dpy, w, XA_WM_ICON_NAME, XA_STRING, 8, PropModeReplace, (_Xconst unsigned char *)icon_name, icon_name ? (int) strlen(icon_name) : 0); Index: xlibi18n/imKStoUCS.c =================================================================== RCS file: /cvsroot/xsrc/external/mit/libX11/dist/src/xlibi18n/imKStoUCS.c,v retrieving revision 1.1.1.5 retrieving revision 1.1.1.6 diff -p -u -r1.1.1.5 -r1.1.1.6 --- xlibi18n/imKStoUCS.c 31 Jul 2020 19:19:49 -0000 1.1.1.5 +++ xlibi18n/imKStoUCS.c 19 May 2021 08:19:12 -0000 1.1.1.6 @@ -285,7 +285,7 @@ KeySymToUcs4(KeySym keysym) return keysym_to_unicode_3a2_3fe[keysym - 0x3a2]; else if (keysym > 0x4a0 && keysym < 0x4e0) return keysym_to_unicode_4a1_4df[keysym - 0x4a1]; - else if (keysym > 0x589 && keysym < 0x5ff) + else if (keysym > 0x58f && keysym < 0x5ff) return keysym_to_unicode_590_5fe[keysym - 0x590]; else if (keysym > 0x67f && keysym < 0x700) return keysym_to_unicode_680_6ff[keysym - 0x680];