cvs: gd /libgd gd.c /libgd/tests CMakeLists.txt /libgd/tests/gdimagecolordeallocate CMakeLists.txt gdimagecolordeallocate.c
[email protected] ("Mattias Bengtsson") Fri, 31 Aug 2007 07:43:58 -0000
| Newsgroups | php.gd.cvs |
|---|---|
| Message-ID | <cvsmattias1188546238@cvsserver> |
mattias Fri Aug 31 07:43:58 2007 UTC
Modified files:
/gd/libgd gd.c
/gd/libgd/tests CMakeLists.txt
/gd/libgd/tests/gdimagecolordeallocate CMakeLists.txt
gdimagecolordeallocate.c
Log:
-MFB #112, gdImageColorDeallocate can write outside buffer
http://cvs.php.net/viewvc.cgi/gd/libgd/gd.c?r1=1.69&r2=1.70&diff_format=u
Index: gd/libgd/gd.c
diff -u gd/libgd/gd.c:1.69 gd/libgd/gd.c:1.70
--- gd/libgd/gd.c:1.69 Thu Aug 30 19:03:06 2007
+++ gd/libgd/gd.c Fri Aug 31 07:43:58 2007
@@ -1,4 +1,4 @@
-/* $Id: gd.c,v 1.69 2007/08/30 19:03:06 mattias Exp $ */
+/* $Id: gd.c,v 1.70 2007/08/31 07:43:58 mattias Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -588,7 +588,7 @@
BGD_DECLARE(void) gdImageColorDeallocate (gdImagePtr im, int color)
{
- if (im->trueColor)
+ if (im->trueColor || (color >= gdMaxColors))
{
return;
}
http://cvs.php.net/viewvc.cgi/gd/libgd/tests/CMakeLists.txt?r1=1.2&r2=1.3&diff_format=u
Index: gd/libgd/tests/CMakeLists.txt
diff -u gd/libgd/tests/CMakeLists.txt:1.2 gd/libgd/tests/CMakeLists.txt:1.3
--- gd/libgd/tests/CMakeLists.txt:1.2 Mon May 7 10:26:44 2007
+++ gd/libgd/tests/CMakeLists.txt Fri Aug 31 07:43:58 2007
@@ -32,6 +32,7 @@
gdimagecolorclosest
gdimagecolorexact
gdimagecolorresolve
+ gdimagecolordeallocate
#gdimageellipse
gdimageline
gdimagefilledellipse
http://cvs.php.net/viewvc.cgi/gd/libgd/tests/gdimagecolordeallocate/CMakeLists.txt?r1=1.1&r2=1.2&diff_format=u
Index: gd/libgd/tests/gdimagecolordeallocate/CMakeLists.txt
diff -u /dev/null gd/libgd/tests/gdimagecolordeallocate/CMakeLists.txt:1.2
--- /dev/null Fri Aug 31 07:43:58 2007
+++ gd/libgd/tests/gdimagecolordeallocate/CMakeLists.txt Fri Aug 31 07:43:58 2007
@@ -0,0 +1,9 @@
+SET(TESTS_FILES
+ gdimagecolordeallocate
+)
+
+FOREACH(test_name ${TESTS_FILES})
+ add_executable(${test_name} "${test_name}.c")
+ target_link_libraries (${test_name} gdTest ${GD_LIB})
+ ADD_TEST("${test_name}" ${EXECUTABLE_OUTPUT_PATH}/${test_name})
+ENDFOREACH(test_name)
http://cvs.php.net/viewvc.cgi/gd/libgd/tests/gdimagecolordeallocate/gdimagecolordeallocate.c?r1=1.1&r2=1.2&diff_format=u
Index: gd/libgd/tests/gdimagecolordeallocate/gdimagecolordeallocate.c
diff -u /dev/null gd/libgd/tests/gdimagecolordeallocate/gdimagecolordeallocate.c:1.2
--- /dev/null Fri Aug 31 07:43:58 2007
+++ gd/libgd/tests/gdimagecolordeallocate/gdimagecolordeallocate.c Fri Aug 31 07:43:58 2007
@@ -0,0 +1,23 @@
+#include <gd.h>
+#include <stdio.h>
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ int error = 0;
+
+ im = gdImageCreate(1, 1);
+
+ im->open[gdMaxColors] = 0;
+
+ gdImageColorDeallocate(im, gdMaxColors);
+
+ if(im->open[gdMaxColors] == 1) {
+ error = -1;
+ }
+
+ gdImageDestroy(im);
+
+ return error;
+}