X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=php_http_api.h;h=694ddc015de9fdfb1b26c8f1bcf1312e51c2f337;hb=14819be2113881e1030d23c6a1a32e17083ab406;hp=c6d08d20b95088da63f584ffd5a817f4ee4bfe4f;hpb=88c32bffeedce1e3c9c611a3444b2d40f8c854a9;p=m6w6%2Fext-http diff --git a/php_http_api.h b/php_http_api.h index c6d08d2..694ddc0 100644 --- a/php_http_api.h +++ b/php_http_api.h @@ -82,6 +82,22 @@ extern void _http_error_ex(long type TSRMLS_DC, long code, const char *format, . action; \ } +#define HTTP_CHECK_OPEN_BASEDIR(file, act) \ + if ((PG(open_basedir) && *PG(open_basedir)) || PG(safe_mode)) \ + { \ + const char *tmp = file; \ + \ + if (!strncasecmp(tmp, "file:", lenof("file:"))) { \ + tmp += lenof("file:"); \ + while (*tmp == '/' || *tmp == '\\') ++tmp; \ + } \ + \ + if (!*tmp || php_check_open_basedir(tmp TSRMLS_CC) || \ + (PG(safe_mode) && !php_checkuid(tmp, "rb+", CHECKUID_CHECK_MODE_PARAM))) { \ + http_error_ex(HE_WARNING, HTTP_E_INVALID_PARAM, "Permission denied: %s", file); \ + act; \ + } \ + } #define http_log(f, i, m) _http_log_ex((f), (i), (m) TSRMLS_CC) extern void http_log_ex(char *file, const char *ident, const char *message TSRMLS_DC);