mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
winicon: Fix potential integer overflow
This commit is contained in:
parent
efb9cc721e
commit
c7af5c6b67
@ -73,13 +73,13 @@ geticonprop(Window win)
|
||||
unsigned long *i;
|
||||
uint32_t bstd = UINT32_MAX, d, m;
|
||||
for (i = p; i < end - 1; i += sz) {
|
||||
if ((w = *i++) > UINT16_MAX || (h = *i++) > UINT16_MAX) { XFree(p); return NULL; }
|
||||
if ((w = *i++) >= 16384 || (h = *i++) >= 16384) { XFree(p); return NULL; }
|
||||
if ((sz = w * h) > end - i) break;
|
||||
if ((m = w > h ? w : h) >= ICONSIZE && (d = m - ICONSIZE) < bstd) { bstd = d; bstp = i; }
|
||||
}
|
||||
if (!bstp) {
|
||||
for (i = p; i < end - 1; i += sz) {
|
||||
if ((w = *i++) > UINT16_MAX || (h = *i++) > UINT16_MAX) { XFree(p); return NULL; }
|
||||
if ((w = *i++) >= 16384 || (h = *i++) >= 16384) { XFree(p); return NULL; }
|
||||
if ((sz = w * h) > end - i) break;
|
||||
if ((d = ICONSIZE - (w > h ? w : h)) < bstd) { bstd = d; bstp = i; }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user