Bug 137246 describes an integer overflow in the GD image library. PHP can either use its internal GD, or the system GD library. In RHEL3, we use the internal GD library. We should use the system GD library rather than the internal PHP library. RHEL2.1 uses the system GD library.
Unfortunately these days PHP includes a specially patched version of GD, switching to the system libgd drops various features.
In fact, it's not unfortunate at all. The PHP libgd reimplements gdMalloc and friends using the PHP internal memory allocation functions safe_emalloc etc; these do check for integer overflow, and they also place a hard limit on the amount of RAM which can be consumed. This successfully catches the issues triggered by the test case referenced. I've been through the PHP libgd checking the places I checked in the real gd, and it everything looks safe.