GNOME Bugzilla – Bug 313818
io-ico.c: check header size overflow
Last modified: 2010-07-10 04:09:20 UTC
io-ico.c (DecodeHeader): 260 if (State->DIBoffset < 0) { ... 271 State->HeaderSize = State->DIBoffset + 40; /* 40 = sizeof(InfoHeader) */ State->DIBoffset can be positive, like G_MAXINT-1, which passes the first check, but will cause State->HeaderSize overflow which is not checked and will later cause crash.
Created attachment 50903 [details] [review] check for header size overflow At first I was attempting to use if (State->DIBoffset < 0 || State->DIBoffset + 40 < 0) { but for reasons I can't quite understand it fails to catch the overflow (with i386 gcc 3.2.3 and 3.3.4.) But if you use separate if to check only for 'State->DIBoffset + 40 < 0' then it seems to work. Given the confusion I think check after assignment is more reliable.
2005-08-18 Matthias Clasen <mclasen@redhat.com> * io-ico.c (DecodeHeader): Check for overflow in one more place. (#313818, Tommi Komulainen)