/* gcc test-invalid-net-wm-icon.c -o test-invalid-net-wm-icon -lX11 */ #include #include #include #include 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); }