Potential Integer Overflow vulnerability in foo2oak.c
Hi, It seems that there exists a potential integer underflow. Please find the following description:
-
rawW can be an arbitrary number https://github.com/koenkooi/foo2zjs/blob/e04290de6b7a30d588f3411fd9834618e09f7b9b/foo2oak.c#L1636 https://github.com/koenkooi/foo2zjs/blob/e04290de6b7a30d588f3411fd9834618e09f7b9b/foo2oak.c#L1639 https://github.com/koenkooi/foo2zjs/blob/e04290de6b7a30d588f3411fd9834618e09f7b9b/foo2oak.c#L1750
-
This can cause underflow and w will not be the intended value https://github.com/koenkooi/foo2zjs/blob/e04290de6b7a30d588f3411fd9834618e09f7b9b/foo2oak.c#L1759
-
Calls pgm_page(buf, w, h, ofp); without checking w https://github.com/koenkooi/foo2zjs/blob/e04290de6b7a30d588f3411fd9834618e09f7b9b/foo2oak.c#L1772
-
Calls pgm_subplanes(subplane, raw, w, h); without checking w https://github.com/koenkooi/foo2zjs/blob/e04290de6b7a30d588f3411fd9834618e09f7b9b/foo2oak.c#L1136
-
Call to memset with the small integer can cause a memory allocation with an underflowed size https://github.com/koenkooi/foo2zjs/blob/e04290de6b7a30d588f3411fd9834618e09f7b9b/foo2oak.c#L675