Skip to content

Commit efd901a

Browse files
committed
Boolify zend_virtual_cwd.c
1 parent 8ebf3b3 commit efd901a

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

Zend/zend_virtual_cwd.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ CWD_API realpath_cache_bucket** realpath_cache_get_buckets(void)
483483
#undef LINK_MAX
484484
#define LINK_MAX 32
485485

486-
static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, time_t *t, int use_realpath, int is_dir, int *link_is_dir) /* {{{ */
486+
static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, time_t *t, int use_realpath, bool is_dir, int *link_is_dir) /* {{{ */
487487
{
488488
size_t i, j;
489489
int directory = 0, save;
@@ -996,7 +996,7 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim
996996
/* }}} */
997997

998998
/* Resolve path relatively to state and put the real path into state */
999-
/* returns 0 for ok, 1 for error */
999+
/* returns 0 for ok, 1 for error, -1 if (path_length >= MAXPATHLEN-1) */
10001000
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath) /* {{{ */
10011001
{
10021002
size_t path_length = strlen(path);
@@ -1005,7 +1005,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
10051005
int ll = 0;
10061006
time_t t;
10071007
int ret;
1008-
int add_slash;
1008+
bool add_slash;
10091009
void *tmp;
10101010

10111011
if (!path_length || path_length >= MAXPATHLEN-1) {
@@ -1178,12 +1178,14 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
11781178
}
11791179
/* }}} */
11801180

1181-
CWD_API int virtual_chdir(const char *path) /* {{{ */
1181+
CWD_API ZEND_RESULT_CODE virtual_chdir(const char *path) /* {{{ */
11821182
{
1183-
return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok, CWD_REALPATH)?-1:0;
1183+
return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok, CWD_REALPATH) ? FAILURE : SUCCESS;
11841184
}
11851185
/* }}} */
11861186

1187+
1188+
/* returns 0 for ok, 1 for empty string, -1 on error */
11871189
CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path)) /* {{{ */
11881190
{
11891191
size_t length = strlen(path);
@@ -1255,6 +1257,7 @@ CWD_API char *virtual_realpath(const char *path, char *real_path) /* {{{ */
12551257
}
12561258
/* }}} */
12571259

1260+
/* returns 0 for ok, 1 for error, -1 if (path_length >= MAXPATHLEN-1) */
12581261
CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path) /* {{{ */
12591262
{
12601263
cwd_state new_state;
@@ -1270,6 +1273,7 @@ CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_f
12701273
}
12711274
/* }}} */
12721275

1276+
/* returns 0 for ok, 1 for error, -1 if (path_length >= MAXPATHLEN-1) */
12731277
CWD_API int virtual_filepath(const char *path, char **filepath) /* {{{ */
12741278
{
12751279
return virtual_filepath_ex(path, filepath, php_is_file_ok);

Zend/zend_virtual_cwd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group, int li
189189
/* One of the following constants must be used as the last argument
190190
in virtual_file_ex() call. */
191191

192+
// TODO Make this into an enum
192193
#define CWD_EXPAND 0 /* expand "." and ".." but don't resolve symlinks */
193194
#define CWD_FILEPATH 1 /* resolve symlinks if file is exist otherwise expand */
194195
#define CWD_REALPATH 2 /* call realpath(), resolve symlinks. File must exist */

0 commit comments

Comments
 (0)