Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 115670
Collapse All | Expand All

(-)php4.4.1/ext/gd/gd.c (-15 / +10 lines)
Lines 18-24 Link Here
18
   +----------------------------------------------------------------------+
18
   +----------------------------------------------------------------------+
19
 */
19
 */
20
20
21
/* $Id: gd.c,v 1.221.2.56.2.1 2005/10/06 20:44:52 iliaa Exp $ */
21
/* $Id: gd.c,v 1.221.2.56.2.3 2005/11/03 20:20:04 sniper Exp $ */
22
22
23
/* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, 
23
/* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, 
24
   Cold Spring Harbor Labs. */
24
   Cold Spring Harbor Labs. */
Lines 623-629 Link Here
623
623
624
	convert_to_string_ex(file);
624
	convert_to_string_ex(file);
625
625
626
	stream = php_stream_open_wrapper(Z_STRVAL_PP(file), "rb", IGNORE_PATH | IGNORE_URL_WIN | REPORT_ERRORS, NULL);
626
	stream = php_stream_open_wrapper(Z_STRVAL_PP(file), "rb", ENFORCE_SAFE_MODE | IGNORE_PATH | IGNORE_URL_WIN | REPORT_ERRORS, NULL);
627
	if (stream == NULL) {
627
	if (stream == NULL) {
628
		RETURN_FALSE;
628
		RETURN_FALSE;
629
	}
629
	}
Lines 807-812 Link Here
807
	convert_to_boolean_ex(dither);
807
	convert_to_boolean_ex(dither);
808
	convert_to_long_ex(ncolors);
808
	convert_to_long_ex(ncolors);
809
809
810
	if (Z_LVAL_PP(ncolors) <= 0) {
811
		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of colors has to be greater than zero");
812
		RETURN_FALSE;
813
	}
810
	gdImageTrueColorToPalette(im, Z_LVAL_PP(dither), Z_LVAL_PP(ncolors));
814
	gdImageTrueColorToPalette(im, Z_LVAL_PP(dither), Z_LVAL_PP(ncolors));
811
815
812
	RETURN_TRUE;
816
	RETURN_TRUE;
Lines 1436-1442 Link Here
1436
1440
1437
	fn = Z_STRVAL_PP(file);
1441
	fn = Z_STRVAL_PP(file);
1438
1442
1439
	stream = php_stream_open_wrapper(fn, "rb", REPORT_ERRORS|IGNORE_PATH|IGNORE_URL_WIN, NULL);
1443
	stream = php_stream_open_wrapper(fn, "rb", ENFORCE_SAFE_MODE|REPORT_ERRORS|IGNORE_PATH|IGNORE_URL_WIN, NULL);
1440
	if (stream == NULL)	{
1444
	if (stream == NULL)	{
1441
		RETURN_FALSE;
1445
		RETURN_FALSE;
1442
	}
1446
	}
Lines 1644-1653 Link Here
1644
	}
1648
	}
1645
1649
1646
	if ((argc == 2) || (argc > 2 && Z_STRLEN_PP(file))) {
1650
	if ((argc == 2) || (argc > 2 && Z_STRLEN_PP(file))) {
1647
		if (!fn || fn == empty_string || php_check_open_basedir(fn TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(fn, "rb+", CHECKUID_CHECK_FILE_AND_DIR))) {
1651
		PHP_GD_CHECK_OPEN_BASEDIR(fn, "Invalid filename");
1648
			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid filename '%s'", fn);
1649
			RETURN_FALSE;
1650
		}
1651
1652
1652
		fp = VCWD_FOPEN(fn, "wb");
1653
		fp = VCWD_FOPEN(fn, "wb");
1653
		if (!fp) {
1654
		if (!fp) {
Lines 3742-3757 Link Here
3742
	}
3743
	}
3743
3744
3744
	/* Check origin file */
3745
	/* Check origin file */
3745
	if (!fn_org || fn_org == empty_string || php_check_open_basedir(fn_org TSRMLS_CC)) {
3746
	PHP_GD_CHECK_OPEN_BASEDIR(fn_org, "Invalid origin filename");
3746
		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid origin filename '%s'", fn_org);
3747
		RETURN_FALSE;
3748
	}
3749
3747
3750
	/* Check destination file */
3748
	/* Check destination file */
3751
	if (!fn_dest || fn_dest == empty_string || php_check_open_basedir(fn_dest TSRMLS_CC)) {
3749
	PHP_GD_CHECK_OPEN_BASEDIR(fn_dest, "Invalid destination filename");
3752
		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid destination filename '%s'", fn_dest);
3753
		RETURN_FALSE;
3754
	}
3755
3750
3756
	/* Open origin file */
3751
	/* Open origin file */
3757
	org = VCWD_FOPEN(fn_org, "rb");
3752
	org = VCWD_FOPEN(fn_org, "rb");
(-)php4.4.1/ext/gd/gd_ctx.c (-4 / +1 lines)
Lines 73-82 Link Here
73
	}
73
	}
74
74
75
	if ((argc == 2) || (argc > 2 && Z_STRLEN_PP(file))) {
75
	if ((argc == 2) || (argc > 2 && Z_STRLEN_PP(file))) {
76
		if (!fn || fn == empty_string || php_check_open_basedir(fn TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(fn, "rb+", CHECKUID_CHECK_FILE_AND_DIR))) {
76
		PHP_GD_CHECK_OPEN_BASEDIR(fn, "Invalid filename");
77
			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid filename '%s'", fn);
78
			RETURN_FALSE;
79
		}
80
77
81
		fp = VCWD_FOPEN(fn, "wb");
78
		fp = VCWD_FOPEN(fn, "wb");
82
		if (!fp) {
79
		if (!fp) {
(-)php4.4.1/ext/gd/php_gd.h (-1 / +10 lines)
Lines 17-23 Link Here
17
   +----------------------------------------------------------------------+
17
   +----------------------------------------------------------------------+
18
*/
18
*/
19
19
20
/* $Id: php_gd.h,v 1.44.2.5 2003/03/31 08:49:30 sniper Exp $ */
20
/* $Id: php_gd.h,v 1.44.2.5.8.2 2005/11/15 08:15:36 sniper Exp $ */
21
21
22
#ifndef PHP_GD_H
22
#ifndef PHP_GD_H
23
#define PHP_GD_H
23
#define PHP_GD_H
Lines 30-35 Link Here
30
30
31
#if HAVE_LIBGD
31
#if HAVE_LIBGD
32
32
33
/* open_basedir and safe_mode checks */
34
#define PHP_GD_CHECK_OPEN_BASEDIR(filename, errormsg)                                   \
35
	if (!filename || filename == empty_string || php_check_open_basedir(filename TSRMLS_CC) || \
36
		(PG(safe_mode) && !php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))   \
37
	) {                                                                                 \
38
		php_error_docref(NULL TSRMLS_CC, E_WARNING, errormsg);                          \
39
		RETURN_FALSE;                                                                   \
40
	}
41
33
#define PHP_GDIMG_TYPE_GIF      1
42
#define PHP_GDIMG_TYPE_GIF      1
34
#define PHP_GDIMG_TYPE_PNG      2
43
#define PHP_GDIMG_TYPE_PNG      2
35
#define PHP_GDIMG_TYPE_JPG      3
44
#define PHP_GDIMG_TYPE_JPG      3

Return to bug 115670