File php-5.1.2-CVE-2007-3477.patch of Package php
--- ext/gd/libgd/gd.c
+++ ext/gd/libgd/gd.c
@@ -1635,14 +1635,30 @@
int lx = 0, ly = 0;
int fx = 0, fy = 0;
- while (s<0) {
- s += 360;
- }
-
- while (e < s) {
- e += 360;
- }
-
+ if ((s % 360) == (e % 360)) {
+ s = 0; e = 360;
+ } else {
+ if (s > 360) {
+ s = s % 360;
+ }
+
+ if (e > 360) {
+ e = e % 360;
+ }
+
+ while (s < 0) {
+ s += 360;
+ }
+
+ while (e < s) {
+ e += 360;
+ }
+
+ if (s == e) {
+ s = 0; e = 360;
+ }
+ }
+
for (i = s; i <= e; i++) {
int x, y;
x = ((long) gdCosT[i % 360] * (long) w / (2 * 1024)) + cx;