1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/* gcc test-invalid-net-wm-icon.c -o test-invalid-net-wm-icon -lX11 */
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <X11/Xlib.h>
Display *d;
Window w;
Atom net_wm_icon;
Atom cardinal;
void test(unsigned int *buffer, unsigned int buffer_length)
{
int length = buffer_length/sizeof(unsigned int);
XChangeProperty(d, w, net_wm_icon, cardinal, 32,
PropModeReplace, (const unsigned char*) buffer, length);
XFlush(d);
sleep(1);
}
int main(int argc, char **argv)
{
/* Invalid _NET_WM_ICON icons */
d = XOpenDisplay(0);
int s = DefaultScreen(d);
net_wm_icon = XInternAtom(d, "_NET_WM_ICON", False);
cardinal = XInternAtom(d, "CARDINAL", False);
XEvent e;
w = XCreateWindow(d, RootWindow(d, s), 0, 0, 200, 200, 0,
CopyFromParent, InputOutput, CopyFromParent, 0, 0);
XMapWindow(d, w);
XFlush(d);
sleep(1);
// sizes are just absurd
unsigned int buffer[] = {-1, -1, 0xFFFFFFFF, 0xFFFFFFFF};
test(buffer, sizeof(buffer));
// sizes are still just absurd
unsigned int buffer1[] = {0x80000001, 0x80000001, 0xFFFFFFFF, 0xFFFFFFFF};
test(buffer1, sizeof(buffer1));
// property should be 256K, but is only 64K
int propsize = 0x10000;
unsigned int *buffer2 = malloc(propsize);
buffer2[0] = 512;
buffer2[1] = 512;
test(buffer2, propsize);
// property is absurdly large, but still not enough for icon
propsize = 0x100000;
unsigned int *buffer3 = malloc(propsize);
assert(buffer3);
buffer3[0] = 0x3000;
buffer3[1] = 0x3000;
test(buffer3, propsize);
while(1) XNextEvent(d, &e);
}
|