From 4875a15ca61358a1c95b156b2279fce092451278 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 19 Jan 2022 00:45:43 +0100 Subject: Update libNX_X11 to upstream's libX11-1.7.3.1-10-gd60ede78 --- nx-X11/lib/src/SetHints.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'nx-X11/lib/src/SetHints.c') diff --git a/nx-X11/lib/src/SetHints.c b/nx-X11/lib/src/SetHints.c index db5e7527e..3997b96c3 100644 --- a/nx-X11/lib/src/SetHints.c +++ b/nx-X11/lib/src/SetHints.c @@ -49,11 +49,13 @@ SOFTWARE. #ifdef HAVE_CONFIG_H #include #endif +#include #include #include #include "Xatomtype.h" #include #include +#include "reallocarray.h" #define safestrlen(s) ((s) ? strlen(s) : 0) @@ -181,10 +183,8 @@ XSetIconSizes ( { register int i; xPropIconSize *pp, *prop; -#define size_of_the_real_thing sizeof /* avoid grepping screwups */ - unsigned nbytes = count * size_of_the_real_thing(xPropIconSize); -#undef size_of_the_real_thing - if ((prop = pp = Xmalloc (nbytes))) { + + if ((prop = pp = Xmallocarray (count, sizeof(xPropIconSize)))) { for (i = 0; i < count; i++) { pp->minWidth = list->min_width; pp->minHeight = list->min_height; @@ -215,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 */ @@ -257,11 +259,13 @@ 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, (_Xconst unsigned char *)icon_string, - safestrlen(icon_string)); + (int)safestrlen(icon_string)); } if (icon_pixmap != None) { @@ -299,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); -- cgit v1.2.3