Skip to content

Commit

Permalink
More TSRMLS_FETCH work. Got it under 400 now.
Browse files Browse the repository at this point in the history
  • Loading branch information
zsuraski committed Jul 31, 2001
1 parent 0b7fdbb commit bc42c37
Show file tree
Hide file tree
Showing 21 changed files with 72 additions and 82 deletions.
16 changes: 8 additions & 8 deletions ext/standard/basic_functions.c
Expand Up @@ -779,13 +779,13 @@ PHP_MINIT_FUNCTION(basic)
#endif

if(PG(allow_url_fopen)) {
if (FAILURE==php_register_url_wrapper("http", php_fopen_url_wrap_http)) {
if (FAILURE==php_register_url_wrapper("http", php_fopen_url_wrap_http TSRMLS_CC)) {
return FAILURE;
}
if (FAILURE==php_register_url_wrapper("ftp", php_fopen_url_wrap_ftp)) {
if (FAILURE==php_register_url_wrapper("ftp", php_fopen_url_wrap_ftp TSRMLS_CC)) {
return FAILURE;
}
if (FAILURE==php_register_url_wrapper("php", php_fopen_url_wrap_php)) {
if (FAILURE==php_register_url_wrapper("php", php_fopen_url_wrap_php TSRMLS_CC)) {
return FAILURE;
}
}
Expand All @@ -803,9 +803,9 @@ PHP_MSHUTDOWN_FUNCTION(basic)
#endif

if(PG(allow_url_fopen)) {
php_unregister_url_wrapper("http");
php_unregister_url_wrapper("ftp");
php_unregister_url_wrapper("php");
php_unregister_url_wrapper("http" TSRMLS_CC);
php_unregister_url_wrapper("ftp" TSRMLS_CC);
php_unregister_url_wrapper("php" TSRMLS_CC);
}

UNREGISTER_INI_ENTRIES();
Expand Down Expand Up @@ -998,7 +998,7 @@ PHP_FUNCTION(getenv)
}


ptr = sapi_getenv(Z_STRVAL_PP(str), Z_STRLEN_PP(str));
ptr = sapi_getenv(Z_STRVAL_PP(str), Z_STRLEN_PP(str) TSRMLS_CC);
if (!ptr) {
ptr = getenv(Z_STRVAL_PP(str));
}
Expand Down Expand Up @@ -1161,7 +1161,7 @@ PHP_FUNCTION(strval)
Flush the output buffer */
PHP_FUNCTION(flush)
{
sapi_flush();
sapi_flush(TSRMLS_C);
}
/* }}} */

Expand Down
2 changes: 1 addition & 1 deletion ext/standard/dir.c
Expand Up @@ -148,7 +148,7 @@ static void _php_do_opendir(INTERNAL_FUNCTION_PARAMETERS, int createobject)
}
convert_to_string_ex(arg);

if (php_check_open_basedir((*arg)->value.str.val)) {
if (php_check_open_basedir((*arg)->value.str.val TSRMLS_CC)) {
RETURN_FALSE;
}

Expand Down
2 changes: 1 addition & 1 deletion ext/standard/exec.c
Expand Up @@ -175,7 +175,7 @@ int php_Exec(int type, char *cmd, pval *array, pval *return_value TSRMLS_DC)

if (type == 1) {
if (output) PUTS(buf);
sapi_flush();
sapi_flush(TSRMLS_C);
}
else if (type == 2) {
/* strip trailing whitespaces */
Expand Down
4 changes: 2 additions & 2 deletions ext/standard/file.c
Expand Up @@ -1907,15 +1907,15 @@ PHP_FUNCTION(copy)
RETURN_FALSE;
}

if (php_check_open_basedir((*source)->value.str.val)) {
if (php_check_open_basedir((*source)->value.str.val TSRMLS_CC)) {
RETURN_FALSE;
}

if (PG(safe_mode) &&(!php_checkuid((*target)->value.str.val, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
RETURN_FALSE;
}

if (php_check_open_basedir((*target)->value.str.val)) {
if (php_check_open_basedir((*target)->value.str.val TSRMLS_CC)) {
RETURN_FALSE;
}

Expand Down
23 changes: 16 additions & 7 deletions ext/standard/filestat.c
Expand Up @@ -141,7 +141,9 @@ PHP_FUNCTION(disk_total_space)

convert_to_string_ex(path);

if (php_check_open_basedir((*path)->value.str.val)) RETURN_FALSE;
if (php_check_open_basedir((*path)->value.str.val TSRMLS_CC)) {
RETURN_FALSE;
}

#ifdef WINDOWS
/* GetDiskFreeSpaceEx is only available in NT and Win95 post-OSR2,
Expand Down Expand Up @@ -242,7 +244,9 @@ PHP_FUNCTION(disk_free_space)

convert_to_string_ex(path);

if (php_check_open_basedir((*path)->value.str.val)) RETURN_FALSE;
if (php_check_open_basedir((*path)->value.str.val TSRMLS_CC)) {
RETURN_FALSE;
}

#ifdef WINDOWS
/* GetDiskFreeSpaceEx is only available in NT and Win95 post-OSR2,
Expand Down Expand Up @@ -335,8 +339,9 @@ PHP_FUNCTION(chgrp)
}

/* Check the basedir */
if (php_check_open_basedir((*filename)->value.str.val))
if (php_check_open_basedir((*filename)->value.str.val TSRMLS_CC)) {
RETURN_FALSE;
}

ret = VCWD_CHOWN((*filename)->value.str.val, -1, gid);
if (ret == -1) {
Expand Down Expand Up @@ -382,8 +387,9 @@ PHP_FUNCTION(chown)
}

/* Check the basedir */
if (php_check_open_basedir((*filename)->value.str.val))
if (php_check_open_basedir((*filename)->value.str.val TSRMLS_CC)) {
RETURN_FALSE;
}

ret = VCWD_CHOWN((*filename)->value.str.val, uid, -1);
if (ret == -1) {
Expand Down Expand Up @@ -414,8 +420,9 @@ PHP_FUNCTION(chmod)
}

/* Check the basedir */
if (php_check_open_basedir((*filename)->value.str.val))
if (php_check_open_basedir((*filename)->value.str.val TSRMLS_CC)) {
RETURN_FALSE;
}

imode = (mode_t) (*mode)->value.lval;
/* in safe mode, do not allow to setuid files.
Expand Down Expand Up @@ -476,8 +483,10 @@ PHP_FUNCTION(touch)
}

/* Check the basedir */
if (php_check_open_basedir((*filename)->value.str.val)) {
if (newtime) efree(newtime);
if (php_check_open_basedir((*filename)->value.str.val TSRMLS_CC)) {
if (newtime) {
efree(newtime);
}
RETURN_FALSE;
}

Expand Down
4 changes: 2 additions & 2 deletions ext/standard/head.c
Expand Up @@ -53,15 +53,15 @@ PHP_FUNCTION(header)
case 1:
convert_to_string_ex(arg1);
}
sapi_add_header_ex(Z_STRVAL_PP(arg1), Z_STRLEN_PP(arg1), 1, replace);
sapi_add_header_ex(Z_STRVAL_PP(arg1), Z_STRLEN_PP(arg1), 1, replace TSRMLS_CC);
}
/* }}} */

PHPAPI int php_header()
{
TSRMLS_FETCH();

if (sapi_send_headers()==FAILURE || SG(request_info).headers_only) {
if (sapi_send_headers(TSRMLS_C)==FAILURE || SG(request_info).headers_only) {
return 0; /* don't allow output */
} else {
return 1; /* allow output */
Expand Down
3 changes: 2 additions & 1 deletion ext/standard/iptc.c
Expand Up @@ -210,8 +210,9 @@ PHP_FUNCTION(iptcembed)
break;
}

if (php_check_open_basedir((*jpeg_file)->value.str.val))
if (php_check_open_basedir((*jpeg_file)->value.str.val TSRMLS_CC)) {
RETURN_FALSE;
}

if ((fp = VCWD_FOPEN((*jpeg_file)->value.str.val,"rb")) == 0) {
php_error(E_WARNING, "Unable to open %s", (*jpeg_file)->value.str.val);
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/pageinfo.c
Expand Up @@ -47,7 +47,7 @@ static void php_statpage(TSRMLS_D)
{
struct stat *pstat;

pstat = sapi_get_stat();
pstat = sapi_get_stat(TSRMLS_C);

if (BG(page_uid)==-1 || BG(page_gid)==-1) {
if(pstat) {
Expand Down
4 changes: 2 additions & 2 deletions ext/zlib/zlib.c
Expand Up @@ -165,7 +165,7 @@ PHP_MINIT_FUNCTION(zlib)
#if HAVE_FOPENCOOKIE

if(PG(allow_url_fopen)) {
php_register_url_wrapper("zlib",zlib_fopen_wrapper);
php_register_url_wrapper("zlib",zlib_fopen_wrapper TSRMLS_CC);
}
#endif

Expand Down Expand Up @@ -202,7 +202,7 @@ PHP_MSHUTDOWN_FUNCTION(zlib)
{
#if HAVE_FOPENCOOKIE
if(PG(allow_url_fopen)) {
php_unregister_url_wrapper("zlib");
php_unregister_url_wrapper("zlib" TSRMLS_CC);
}
#endif

Expand Down
18 changes: 5 additions & 13 deletions main/SAPI.c
Expand Up @@ -366,12 +366,11 @@ static int sapi_extract_response_code(const char *header_line)
/* This function expects a *duplicated* string, that was previously emalloc()'d.
* Pointers sent to this functions will be automatically freed by the framework.
*/
SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bool duplicate, zend_bool replace)
SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bool duplicate, zend_bool replace TSRMLS_DC)
{
int retval, free_header = 0;
sapi_header_struct sapi_header;
char *colon_offset;
TSRMLS_FETCH();

if (SG(headers_sent) && !SG(request_info).no_headers) {
char *output_start_filename = php_get_output_start_filename();
Expand Down Expand Up @@ -465,11 +464,10 @@ SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bo
}


SAPI_API int sapi_send_headers()
SAPI_API int sapi_send_headers(TSRMLS_D)
{
int retval;
int ret = FAILURE;
TSRMLS_FETCH();

if (SG(headers_sent) || SG(request_info).no_headers) {
return SUCCESS;
Expand Down Expand Up @@ -555,22 +553,18 @@ SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(TSRML
}


SAPI_API int sapi_flush()
SAPI_API int sapi_flush(TSRMLS_D)
{
if (sapi_module.flush) {
TSRMLS_FETCH();

sapi_module.flush(SG(server_context));
return SUCCESS;
} else {
return FAILURE;
}
}

SAPI_API struct stat *sapi_get_stat()
SAPI_API struct stat *sapi_get_stat(TSRMLS_D)
{
TSRMLS_FETCH();

if (sapi_module.get_stat) {
return sapi_module.get_stat(TSRMLS_C);
} else {
Expand All @@ -582,11 +576,9 @@ SAPI_API struct stat *sapi_get_stat()
}


SAPI_API char *sapi_getenv(char *name, size_t name_len)
SAPI_API char *sapi_getenv(char *name, size_t name_len TSRMLS_DC)
{
if (sapi_module.getenv) {
TSRMLS_FETCH();

return sapi_module.getenv(name, name_len TSRMLS_CC);
} else {
return NULL;
Expand Down
12 changes: 6 additions & 6 deletions main/SAPI.h
Expand Up @@ -130,10 +130,10 @@ SAPI_API void sapi_activate(TSRMLS_D);
SAPI_API void sapi_deactivate(TSRMLS_D);
SAPI_API void sapi_initialize_empty_request(TSRMLS_D);

SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bool duplicate, zend_bool replace);
SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bool duplicate, zend_bool replace TSRMLS_DC);
#define sapi_add_header(header_line, header_line_len, duplicate) \
sapi_add_header_ex((header_line), (header_line_len), (duplicate), 1)
SAPI_API int sapi_send_headers(void);
sapi_add_header_ex((header_line), (header_line_len), (duplicate), 1 TSRMLS_CC)
SAPI_API int sapi_send_headers(TSRMLS_D);
SAPI_API void sapi_free_header(sapi_header_struct *sapi_header);
SAPI_API void sapi_handle_post(void *arg TSRMLS_DC);

Expand All @@ -142,9 +142,9 @@ SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry);
SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry);
SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(TSRMLS_D));

SAPI_API int sapi_flush(void);
SAPI_API struct stat *sapi_get_stat(void);
SAPI_API char *sapi_getenv(char *name, size_t name_len);
SAPI_API int sapi_flush(TSRMLS_D);
SAPI_API struct stat *sapi_get_stat(TSRMLS_D);
SAPI_API char *sapi_getenv(char *name, size_t name_len TSRMLS_DC);

SAPI_API char *sapi_get_default_content_type(TSRMLS_D);
SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_header TSRMLS_DC);
Expand Down
28 changes: 9 additions & 19 deletions main/fopen_wrappers.c
Expand Up @@ -90,10 +90,8 @@ HashTable fopen_url_wrappers_hash;

/* {{{ php_register_url_wrapper
*/
PHPAPI int php_register_url_wrapper(char *protocol, FILE * (*wrapper)(char *path, char *mode, int options, int *issock, int *socketd, char **opened_path))
PHPAPI int php_register_url_wrapper(char *protocol, FILE * (*wrapper)(char *path, char *mode, int options, int *issock, int *socketd, char **opened_path) TSRMLS_DC)
{
TSRMLS_FETCH();

if(PG(allow_url_fopen)) {
return zend_hash_add(&fopen_url_wrappers_hash, protocol, strlen(protocol), &wrapper, sizeof(wrapper), NULL);
} else {
Expand All @@ -104,10 +102,8 @@ PHPAPI int php_register_url_wrapper(char *protocol, FILE * (*wrapper)(char *path

/* {{{ php_unregister_url_wrapper
*/
PHPAPI int php_unregister_url_wrapper(char *protocol)
PHPAPI int php_unregister_url_wrapper(char *protocol TSRMLS_DC)
{
TSRMLS_FETCH();

if(PG(allow_url_fopen)) {
return zend_hash_del(&fopen_url_wrappers_hash, protocol, strlen(protocol));
} else {
Expand All @@ -118,27 +114,22 @@ PHPAPI int php_unregister_url_wrapper(char *protocol)

/* {{{ php_init_fopen_wrappers
*/
int php_init_fopen_wrappers(void)
int php_init_fopen_wrappers(TSRMLS_D)
{
TSRMLS_FETCH();

if(PG(allow_url_fopen))
if(PG(allow_url_fopen)) {
return zend_hash_init(&fopen_url_wrappers_hash, 0, NULL, NULL, 1);

}
return SUCCESS;
}
/* }}} */

/* {{{ php_shutdown_fopen_wrappers
*/
int php_shutdown_fopen_wrappers(void)
int php_shutdown_fopen_wrappers(TSRMLS_D)
{
TSRMLS_FETCH();

if(PG(allow_url_fopen)) {
zend_hash_destroy(&fopen_url_wrappers_hash);
}

return SUCCESS;
}
/* }}} */
Expand Down Expand Up @@ -196,10 +187,8 @@ PHPAPI int php_check_specific_open_basedir(char *basedir, char *path TSRMLS_DC)

/* {{{ php_check_open_basedir
*/
PHPAPI int php_check_open_basedir(char *path)
PHPAPI int php_check_open_basedir(char *path TSRMLS_DC)
{
TSRMLS_FETCH();

/* Only check when open_basedir is available */
if (PG(open_basedir) && *PG(open_basedir)) {
char *pathbuf;
Expand Down Expand Up @@ -240,8 +229,9 @@ PHPAPI int php_check_open_basedir(char *path)
static FILE *php_fopen_and_set_opened_path(const char *path, char *mode, char **opened_path)
{
FILE *fp;
TSRMLS_FETCH();

if (php_check_open_basedir((char *)path)) {
if (php_check_open_basedir((char *)path TSRMLS_CC)) {
return NULL;
}
fp = VCWD_FOPEN(path, mode);
Expand Down

0 comments on commit bc42c37

Please sign in to comment.