This source file includes following definitions.
- gdJpegGetVersionInt
- gdJpegGetVersionString
- gdPngGetVersionString
- overflow2
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
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
20 int gdJpegGetVersionInt()
21 {
22 return JPEG_LIB_VERSION;
23 }
24
25 const 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
47 const char * gdPngGetVersionString()
48 {
49 return PNG_LIBPNG_VER_STRING;
50 }
51 #endif
52
53 int overflow2(int a, int b)
54 {
55
56 if(a <= 0 || b <= 0) {
57 php_error_docref(NULL, E_WARNING, "gd warning: one parameter to a memory allocation multiplication is negative or zero, failing operation gracefully\n");
58 return 1;
59 }
60 if(a > INT_MAX / b) {
61 php_error_docref(NULL, E_WARNING, "gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully\n");
62 return 1;
63 }
64 return 0;
65 }
66