aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/src/SetHints.c
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/lib/src/SetHints.c')
-rw-r--r--nx-X11/lib/src/SetHints.c16
1 files changed, 11 insertions, 5 deletions
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 <config.h>
#endif
+#include <limits.h>
#include <nx-X11/Xlibint.h>
#include <nx-X11/Xutil.h>
#include "Xatomtype.h"
#include <nx-X11/Xatom.h>
#include <nx-X11/Xos.h>
+#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);