Skip to content

Commit

Permalink
Added missing open_basedir & safe_mode checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilia Alshanetsky committed May 21, 2003
1 parent 18954d8 commit e953bbb
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions ext/fdf/fdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ PHP_FUNCTION(fdf_open)

convert_to_string_ex(file);

if (php_check_open_basedir(Z_STRVAL_PP(file) TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(Z_STRVAL_PP(file), "wb+", CHECKUID_CHECK_MODE_PARAM))) {
RETURN_FALSE;
}

err = FDFOpen(Z_STRVAL_PP(file), 0, &fdf);

if(err != FDFErcOK || !fdf) {
Expand Down Expand Up @@ -511,6 +515,11 @@ PHP_FUNCTION(fdf_set_ap)
convert_to_string_ex(fieldname);
convert_to_long_ex(face);
convert_to_string_ex(filename);

if (php_check_open_basedir(Z_STRVAL_PP(filename) TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(Z_STRVAL_PP(filename), "wb+", CHECKUID_CHECK_MODE_PARAM))) {
RETURN_FALSE;
}

convert_to_long_ex(pagenr);

switch(Z_LVAL_PP(face)) {
Expand Down Expand Up @@ -562,6 +571,10 @@ PHP_FUNCTION(fdf_get_ap) {

ZEND_FETCH_RESOURCE(fdf, FDFDoc *, &r_fdf, -1, "fdf", le_fdf);

if (php_check_open_basedir(filename TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(filename, "wb+", CHECKUID_CHECK_MODE_PARAM))) {
RETURN_FALSE;
}

switch(face) {
case 1:
facenr = FDFNormalAP;
Expand Down Expand Up @@ -771,6 +784,9 @@ PHP_FUNCTION(fdf_save)
ZEND_FETCH_RESOURCE(fdf, FDFDoc *, &r_fdf, -1, "fdf", le_fdf);

if(filename) {
if (php_check_open_basedir(filename TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(filename, "wb+", CHECKUID_CHECK_MODE_PARAM))) {
RETURN_FALSE;
}
err = FDFSave(fdf, filename);
} else {
FILE *fp;
Expand Down Expand Up @@ -885,6 +901,10 @@ PHP_FUNCTION(fdf_add_template)
convert_to_string_ex(template);
convert_to_long_ex(rename);

if (php_check_open_basedir(Z_STRVAL_PP(filename) TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(Z_STRVAL_PP(filename), "wb+", CHECKUID_CHECK_MODE_PARAM))) {
RETURN_FALSE;
}

filespec.FS = NULL;
filespec.F = Z_STRVAL_PP(filename);
filespec.Mac = NULL;
Expand Down

0 comments on commit e953bbb

Please sign in to comment.