diff options
Diffstat (limited to 'php_imlib.c')
| -rw-r--r-- | php_imlib.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/php_imlib.c b/php_imlib.c index 5422631..c142ef4 100644 --- a/php_imlib.c +++ b/php_imlib.c @@ -2028,6 +2028,8 @@ PHP_FUNCTION(imlib_load_font) zval **fontname, **encoding; PHP_Imlib_Font fn; int argc; + char* filename; + FILE* f; argc=ZEND_NUM_ARGS(); if (argc < 1 || argc > 2 || zend_get_parameters_ex(argc, &fontname, &encoding) == FAILURE) { @@ -2051,7 +2053,14 @@ PHP_FUNCTION(imlib_load_font) } convert_to_string_ex(fontname); - fn->font = imlib_load_font(Z_STRVAL_PP(fontname)); + + f = php_stream_open_wrapper_as_file(Z_STRVAL_PP(fontname), "rb", IGNORE_PATH | ENFORCE_SAFE_MODE | REPORT_ERRORS, &filename); + if (f == NULL) RETURN_FALSE; + + fn->font = imlib_load_font(filename); + + fclose(f); + efree(filename); if (!fn->font) { @@ -2935,6 +2944,8 @@ PHP_FUNCTION(imlib_psloadfont) #if HAVE_LIBT1 zval **file; int f_ind, *font; + char* filename; + FILE* f; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &file) == FAILURE) { ZEND_WRONG_PARAM_COUNT(); @@ -2942,7 +2953,13 @@ PHP_FUNCTION(imlib_psloadfont) convert_to_string_ex(file); - f_ind = T1_AddFont(Z_STRVAL_PP(file)); + f = php_stream_open_wrapper_as_file(Z_STRVAL_PP(file), "rb", IGNORE_PATH | ENFORCE_SAFE_MODE | REPORT_ERRORS, &filename); + if (f == NULL) RETURN_FALSE; + + f_ind = T1_AddFont(filename); + + fclose(f); + efree(filename); if (f_ind < 0) { switch (f_ind) { @@ -3007,6 +3024,8 @@ PHP_FUNCTION(imlib_psencodefont) zval **fnt, **enc; char **enc_vector; int *f_ind; + char* filename; + FILE* f; if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &fnt, &enc) == FAILURE) { ZEND_WRONG_PARAM_COUNT(); @@ -3016,7 +3035,15 @@ PHP_FUNCTION(imlib_psencodefont) ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", le_ps_font); - if ((enc_vector = T1_LoadEncoding(Z_STRVAL_PP(enc))) == NULL) { + f = php_stream_open_wrapper_as_file(Z_STRVAL_PP(enc), "rb", IGNORE_PATH | ENFORCE_SAFE_MODE | REPORT_ERRORS, &filename); + if (f == NULL) RETURN_FALSE; + + enc_vector = T1_LoadEncoding(filename); + + fclose(f); + efree(filename); + + if (enc_vector == NULL) { php_error(E_WARNING, "Couldn't load encoding vector from %s", Z_STRVAL_PP(enc)); RETURN_FALSE; } |
