com php-src: (re)allow WBMP detection with system libgd provide getbmi and skipheader not exported functions in gd_compat.: ext/gd /gd.c
ext/gd/libgd/gd_compat.c ext/gd/libgd/gd_comp at.h
| From: | Remi Collet | Date: | Tue, 23 Apr 2013 11:43:57 +0000 |
| Subject: | com php-src: (re)allow WBMP detection with system libgd provide getbmi and skipheader not exported functions in gd_compat.: ext/gd /gd.c ext/gd/libgd/gd_compat.c ext/gd/libgd/gd_comp at.h |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-71980@lists.php.net to get a copy of this message | ||
Commit: eb50789910410179565e8f2114d80011e34c0ad7
Author: Remi Collet <remi@php.net> Tue, 23 Apr 2013 13:43:57 +0200
Parents: 734e165d4e427feca9a736b62832a2ff287a22c9
Branches: PHP-5.5 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=eb50789910410179565e8f2114d80011e34c0ad7
Log:
(re)allow WBMP detection with system libgd
provide getbmi and skipheader not exported functions in gd_compat.
Changed paths:
M ext/gd/gd.c
M ext/gd/libgd/gd_compat.c
M ext/gd/libgd/gd_compat.h
Diff:
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index 6cafb51..203ae24 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -2403,14 +2403,12 @@ static int _php_image_type (char data[8])
} else if (!memcmp(data, php_sig_gif, 3)) {
return PHP_GDIMG_TYPE_GIF;
}
-/* Temporary disabled, as gdGetC, getmbi and skipheader not exported in system libgd */
-#if HAVE_GD_BUNDLED
#ifdef HAVE_GD_WBMP
else {
gdIOCtx *io_ctx;
io_ctx = gdNewDynamicCtxEx(8, data, 0);
if (io_ctx) {
- if (getmbi((int(*)(void *)) gdGetC, io_ctx) == 0 && skipheader((int(*)(void *)) gdGetC,
io_ctx) == 0 ) {
+ if (getmbi((int(*)(void *)) io_ctx->getC, io_ctx) == 0 && skipheader((int(*)(void *))
io_ctx->getC, io_ctx) == 0 ) {
#if HAVE_LIBGD204
io_ctx->gd_free(io_ctx);
#else
@@ -2427,7 +2425,6 @@ static int _php_image_type (char data[8])
}
}
#endif
-#endif
return -1;
#endif
}
diff --git a/ext/gd/libgd/gd_compat.c b/ext/gd/libgd/gd_compat.c
index b563290..f3627a1 100644
--- a/ext/gd/libgd/gd_compat.c
+++ b/ext/gd/libgd/gd_compat.c
@@ -33,6 +33,7 @@ const char * gdPngGetVersionString()
}
#endif
+/* Not exported by libgd, copied from gdhelpers.h */
int overflow2(int a, int b)
{
if(a <= 0 || b <= 0) {
@@ -44,3 +45,38 @@ int overflow2(int a, int b)
return 0;
}
+/* Not exported by libgd, copied from wbmp.c */
+int
+getmbi (int (*getin) (void *in), void *in)
+{
+ int i, mbi = 0;
+
+ do
+ {
+ i = getin (in);
+ if (i < 0)
+ return (-1);
+ mbi = (mbi << 7) | (i & 0x7f);
+ }
+ while (i & 0x80);
+
+ return (mbi);
+}
+
+/* Not exported by libgd, copied from wbmp.c */
+int
+skipheader (int (*getin) (void *in), void *in)
+{
+ int i;
+
+ do
+ {
+ i = getin (in);
+ if (i < 0)
+ return (-1);
+ }
+ while (i & 0x80);
+
+ return (0);
+}
+
diff --git a/ext/gd/libgd/gd_compat.h b/ext/gd/libgd/gd_compat.h
index 779e709..e8fedf8 100644
--- a/ext/gd/libgd/gd_compat.h
+++ b/ext/gd/libgd/gd_compat.h
@@ -11,6 +11,9 @@ const char * gdPngGetVersionString();
const char * gdJpegGetVersionString();
int gdJpegGetVersionInt();
int overflow2(int a, int b);
+int getmbi (int (*getin) (void *in), void *in);
+int skipheader (int (*getin) (void *in), void *in);
+
/* filters section
*