diff options
author | Mathias Gumz <akira at fluxbox dot org> | 2008-09-11 14:21:51 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2008-09-11 14:21:51 (GMT) |
commit | 8d0fb85bbc8eb1267f934873ddee285b0eb3f5f1 (patch) | |
tree | 716ac1dec7eb7cf388e5f6e2e42145b7360d35ab | |
parent | 68bf9796e8d371d5824b2bd04a07db22d97b35e6 (diff) | |
download | fluxbox-8d0fb85bbc8eb1267f934873ddee285b0eb3f5f1.zip fluxbox-8d0fb85bbc8eb1267f934873ddee285b0eb3f5f1.tar.bz2 |
be aware of badly specified _NET_WM_ICONS
-rw-r--r-- | src/Ewmh.cc | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/Ewmh.cc b/src/Ewmh.cc index aacb2ed..14c74c6 100644 --- a/src/Ewmh.cc +++ b/src/Ewmh.cc | |||
@@ -109,10 +109,15 @@ void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) { | |||
109 | 109 | ||
110 | // read all the icons stored in _NET_WM_ICON | 110 | // read all the icons stored in _NET_WM_ICON |
111 | if (raw_data) | 111 | if (raw_data) |
112 | XFree(raw_data); | 112 | XFree(raw_data); |
113 | winclient.property(net_wm_icon, 0L, nr_icon_data, False, XA_CARDINAL, | 113 | |
114 | // something went wrong | ||
115 | if (!winclient.property(net_wm_icon, 0L, nr_icon_data, False, XA_CARDINAL, | ||
114 | &rtype, &rfmt, &nr_read, &nr_bytes_left, | 116 | &rtype, &rfmt, &nr_read, &nr_bytes_left, |
115 | reinterpret_cast<unsigned char**>(&raw_data)); | 117 | reinterpret_cast<unsigned char**>(&raw_data))) { |
118 | |||
119 | return; | ||
120 | } | ||
116 | } | 121 | } |
117 | 122 | ||
118 | IconContainer icon_data; // stores all available data, sorted by size (width x height) | 123 | IconContainer icon_data; // stores all available data, sorted by size (width x height) |
@@ -121,11 +126,19 @@ void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) { | |||
121 | 126 | ||
122 | // analyze the available icons | 127 | // analyze the available icons |
123 | long i; | 128 | long i; |
124 | for (i = 0; i < nr_icon_data; i += width * height ) { | 129 | |
130 | for (i = 0; i + 2 < nr_icon_data; i += width * height ) { | ||
125 | 131 | ||
126 | width = raw_data[i++]; | 132 | width = raw_data[i++]; |
127 | height = raw_data[i++]; | 133 | height = raw_data[i++]; |
128 | 134 | ||
135 | // strange values stored in the NETWM_ICON | ||
136 | if (width <= 0 || height <= 0 || i + width * height > nr_icon_data) { | ||
137 | std::cerr << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON dimensions for " << winclient.title() << "\n"; | ||
138 | XFree(raw_data); | ||
139 | return; | ||
140 | } | ||
141 | |||
129 | icon_data[Size(width, height)] = &raw_data[i]; | 142 | icon_data[Size(width, height)] = &raw_data[i]; |
130 | } | 143 | } |
131 | 144 | ||