1 #ifdef HAVE_CONFIG_H 2 #include "config.h" 3 #else 4 #include "php_config.h" 5 #endif 6 7 #ifdef HAVE_GD_PNG 8 /* needs to be first */ 9 # include <png.h> 10 #endif 11 12 #ifdef HAVE_GD_JPG 13 # include <jpeglib.h> 14 #endif 15 16 #include "gd_compat.h" 17 #include "php.h" 18 19 #ifdef HAVE_GD_JPG gdJpegGetVersionInt()20int gdJpegGetVersionInt() 21 { 22 return JPEG_LIB_VERSION; 23 } 24 gdJpegGetVersionString()25const char * gdJpegGetVersionString() 26 { 27 switch(JPEG_LIB_VERSION) { 28 case 62: 29 return "6b"; 30 break; 31 32 case 70: 33 return "7"; 34 break; 35 36 case 80: 37 return "8"; 38 break; 39 40 default: 41 return "unknown"; 42 } 43 } 44 #endif 45 46 #ifdef HAVE_GD_PNG gdPngGetVersionString()47const char * gdPngGetVersionString() 48 { 49 return PNG_LIBPNG_VER_STRING; 50 } 51 #endif 52 overflow2(int a,int b)53int overflow2(int a, int b) 54 { 55 TSRMLS_FETCH(); 56 57 if(a <= 0 || b <= 0) { 58 php_error_docref(NULL TSRMLS_CC, E_WARNING, "gd warning: one parameter to a memory allocation multiplication is negative or zero, failing operation gracefully\n"); 59 return 1; 60 } 61 if(a > INT_MAX / b) { 62 php_error_docref(NULL TSRMLS_CC, E_WARNING, "gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully\n"); 63 return 1; 64 } 65 return 0; 66 } 67 68