com php-src: Fixed Bug #64962 imagerotate produce corrup ted image: NEWS ext/gd/libgd/gd_interpolation.c

From: Date: Mon, 03 Jun 2013 13:01:48 +0000
Subject: com php-src: Fixed Bug #64962 imagerotate produce corrup ted image: NEWS ext/gd/libgd/gd_interpolation.c
Groups: php.cvs 
Request: Send a blank email to [email protected] to get a copy of this message
Commit:    3579e81200927b75b2c5f353e016ec26d8884c26
Author:    Remi Collet <[email protected]>         Mon, 3 Jun 2013 15:01:48 +0200
Parents:   245e103ed397da272dbd0bf02ce221ae6bcbbdef
Branches:  PHP-5.5 master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=3579e81200927b75b2c5f353e016ec26d8884c26

Log:
Fixed Bug #64962 	imagerotate produce corrupted image

See https://bitbucket.org/libgd/gd-libgd/issue/67/problem-with-gdrotate

This computation need to be done in signed range.

Bugs:
https://bugs.php.net/64962

Changed paths:
  M  NEWS
  M  ext/gd/libgd/gd_interpolation.c


Diff:
diff --git a/NEWS b/NEWS
index c09b009..25e3b20 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ PHP                                                                        NEWS
 
 - GD:
   . Fixed Bug #64961 (segfault in imagesetinterpolation). (Remi)
+  . Fixed Bug #64962 (imagerotate produces corrupted image). (Remi)
 
 - Hash:
   . Fixed Bug #64745 (hash_pbkdf2() truncates data when using default length
diff --git a/ext/gd/libgd/gd_interpolation..c b/ext/gd/libgd/gd_interpolation.c
index bcd76e9..9652a3a 100644
--- a/ext/gd/libgd/gd_interpolation.c
+++ b/ext/gd/libgd/gd_interpolation.c
@@ -1690,8 +1690,8 @@ gdImagePtr gdImageRotateNearestNeighbour(gdImagePtr src, const float degrees,
co
 		unsigned int j;
 		dst_offset_x = 0;
 		for (j = 0; j < new_width; j++) {
-			gdFixed f_i = gd_itofx(i - new_height/2);
-			gdFixed f_j = gd_itofx(j-new_width/2);
+			gdFixed f_i = gd_itofx((int)i - (int)new_height/2);
+			gdFixed f_j = gd_itofx((int)j - (int)new_width/2);
 			gdFixed f_m = gd_mulfx(f_j,f_sin) + gd_mulfx(f_i,f_cos) + f_0_5 + f_H;
 			gdFixed f_n = gd_mulfx(f_j,f_cos) - gd_mulfx(f_i,f_sin) + f_0_5 + f_W;
 			long m = gd_fxtoi(f_m);
@@ -1753,8 +1753,8 @@ gdImagePtr gdImageRotateGeneric(gdImagePtr src, const float degrees, const int
b
 		unsigned int j;
 		dst_offset_x = 0;
 		for (j = 0; j < new_width; j++) {
-			gdFixed f_i = gd_itofx(i - new_height/ 2);
-			gdFixed f_j = gd_itofx(j  -new_width / 2);
+			gdFixed f_i = gd_itofx((int)i - (int)new_height/ 2);
+			gdFixed f_j = gd_itofx((int)j - (int)new_width / 2);
 			gdFixed f_m = gd_mulfx(f_j,f_sin) + gd_mulfx(f_i,f_cos) + f_0_5 + f_H;
 			gdFixed f_n = gd_mulfx(f_j,f_cos) - gd_mulfx(f_i,f_sin) + f_0_5 + f_W;
 			long m = gd_fxtoi(f_m);
@@ -1814,8 +1814,8 @@ gdImagePtr gdImageRotateBilinear(gdImagePtr src, const float degrees, const
int
 		dst_offset_x = 0;
 
 		for (j=0; j < new_width; j++) {
-			const gdFixed f_i = gd_itofx(i-new_height/2);
-			const gdFixed f_j = gd_itofx(j-new_width/2);
+			const gdFixed f_i = gd_itofx((int)i - (int)new_height/2);
+			const gdFixed f_j = gd_itofx((int)j - (int)new_width/2);
 			const gdFixed f_m = gd_mulfx(f_j,f_sin) + gd_mulfx(f_i,f_cos) + f_0_5 + f_H;
 			const gdFixed f_n = gd_mulfx(f_j,f_cos) - gd_mulfx(f_i,f_sin) + f_0_5 + f_W;
 			const unsigned int m = gd_fxtoi(f_m);
@@ -1941,8 +1941,8 @@ gdImagePtr gdImageRotateBicubicFixed(gdImagePtr src, const float degrees,
const
 		dst_offset_x = 0;
 
 		for (j=0; j < new_width; j++) {
-			const gdFixed f_i = gd_itofx(i-new_height/2);
-			const gdFixed f_j = gd_itofx(j-new_width/2);
+			const gdFixed f_i = gd_itofx((int)i - (int)new_height/2);
+			const gdFixed f_j = gd_itofx((int)j - (int)new_width/2);
 			const gdFixed f_m = gd_mulfx(f_j,f_sin) + gd_mulfx(f_i,f_cos) + f_0_5 + f_H;
 			const gdFixed f_n = gd_mulfx(f_j,f_cos) - gd_mulfx(f_i,f_sin) + f_0_5 + f_W;
 			const int m = gd_fxtoi(f_m);



Thread (1 message)

  • Remi Collet
« previous php.cvs (#72286) next »