check and restrict size hint values
Could not reproduce a crash, but may mess up window geometry, etc.
Test program below to give an idea:
cc repro.c -o repro -lX11; ./repro
int
main(void)
{
Display *d;
int screen;
Window root;
Window win;
d = XOpenDisplay(NULL);
if (!d) {
fprintf(stderr, "XOpenDisplay failed\n");
return 1;
}
screen = DefaultScreen(d);
root = RootWindow(d, screen);
win = XCreateSimpleWindow(d, root, 0, 0, 100, 100, 0, 0, 0);
if (!win) {
fprintf(stderr, "XCreateSimpleWindow failed\n");
XCloseDisplay(d);
return 1;
}
//XMapWindow(d, win);
XMapRaised(d, win);
XSizeHints h = {0};
h.flags = PResizeInc | PBaseSize | PMinSize;
h.width_inc = -1;
h.height_inc = -1;
h.base_width = INT_MIN + 500; /* window is 500px wide */
h.base_height = 0;
h.min_width = ~0L;
h.min_height = ~0L;
XSetWMNormalHints(d, win, &h);
sleep(3);
//XDestroyWindow(d, win);
XCloseDisplay(d);
return 0;
}
This commit is contained in:
1 parent
44dbc6809d
commit
7283c8c0ac
1 file changed
+13
-13
@@ -1968,32 +1968,32 @@ updatesizehints(Client *c)
|
|||||||
/* size is uninitialized, ensure that size.flags aren't used */
|
/* size is uninitialized, ensure that size.flags aren't used */
|
||||||
size.flags = PSize;
|
size.flags = PSize;
|
||||||
if (size.flags & PBaseSize) {
|
if (size.flags & PBaseSize) {
|
||||||
c->basew = size.base_width;
|
c->basew = MAX(0, size.base_width);
|
||||||
c->baseh = size.base_height;
|
c->baseh = MAX(0, size.base_height);
|
||||||
} else if (size.flags & PMinSize) {
|
} else if (size.flags & PMinSize) {
|
||||||
c->basew = size.min_width;
|
c->basew = MAX(0, size.min_width);
|
||||||
c->baseh = size.min_height;
|
c->baseh = MAX(0, size.min_height);
|
||||||
} else
|
} else
|
||||||
c->basew = c->baseh = 0;
|
c->basew = c->baseh = 0;
|
||||||
if (size.flags & PResizeInc) {
|
if (size.flags & PResizeInc) {
|
||||||
c->incw = size.width_inc;
|
c->incw = MAX(0, size.width_inc);
|
||||||
c->inch = size.height_inc;
|
c->inch = MAX(0, size.height_inc);
|
||||||
} else
|
} else
|
||||||
c->incw = c->inch = 0;
|
c->incw = c->inch = 0;
|
||||||
if (size.flags & PMaxSize) {
|
if (size.flags & PMaxSize) {
|
||||||
c->maxw = size.max_width;
|
c->maxw = MAX(0, size.max_width);
|
||||||
c->maxh = size.max_height;
|
c->maxh = MAX(0, size.max_height);
|
||||||
} else
|
} else
|
||||||
c->maxw = c->maxh = 0;
|
c->maxw = c->maxh = 0;
|
||||||
if (size.flags & PMinSize) {
|
if (size.flags & PMinSize) {
|
||||||
c->minw = size.min_width;
|
c->minw = MAX(0, size.min_width);
|
||||||
c->minh = size.min_height;
|
c->minh = MAX(0, size.min_height);
|
||||||
} else if (size.flags & PBaseSize) {
|
} else if (size.flags & PBaseSize) {
|
||||||
c->minw = size.base_width;
|
c->minw = MAX(0, size.base_width);
|
||||||
c->minh = size.base_height;
|
c->minh = MAX(0, size.base_height);
|
||||||
} else
|
} else
|
||||||
c->minw = c->minh = 0;
|
c->minw = c->minh = 0;
|
||||||
if (size.flags & PAspect) {
|
if ((size.flags & PAspect) && size.min_aspect.x > 0 && size.max_aspect.y > 0) {
|
||||||
c->mina = (float)size.min_aspect.y / size.min_aspect.x;
|
c->mina = (float)size.min_aspect.y / size.min_aspect.x;
|
||||||
c->maxa = (float)size.max_aspect.x / size.max_aspect.y;
|
c->maxa = (float)size.max_aspect.x / size.max_aspect.y;
|
||||||
} else
|
} else
|
||||||
|
|||||||
Reference in new issue
Block a user