Skip to content

Commit 49d9b30

Browse files
committed
Move cwd_state and path related routines to size_t
Having `int` there is no real profit in the size or speed, while unsigned improves security and overall integration. ZPP supplied strings can be then accepted directly and structs can be still handled with smaller unsigned types for size reasons, which is safe. Yet some related places are to go. basic move tsrm_realpath_r to size_t fix conditions and sync with affected places touch ocurrences of php_sys_readlink usage follow up on phar path handling remove duplicated check move zend_resolve_path and related pieces to size_t touch yet resolve path related places remove cast missing pieces missing piece yet cleanups for php_sys_readlink for ssize_t fix wrong return
1 parent 00bed31 commit 49d9b30

19 files changed

+113
-108
lines changed

Zend/zend.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint3
7575
void (*zend_printf_to_smart_string)(smart_string *buf, const char *format, va_list ap);
7676
void (*zend_printf_to_smart_str)(smart_str *buf, const char *format, va_list ap);
7777
ZEND_API char *(*zend_getenv)(char *name, size_t name_len);
78-
ZEND_API zend_string *(*zend_resolve_path)(const char *filename, int filename_len);
78+
ZEND_API zend_string *(*zend_resolve_path)(const char *filename, size_t filename_len);
7979

8080
void (*zend_on_timeout)(int seconds);
8181

Zend/zend.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ typedef struct _zend_utility_functions {
189189
void (*printf_to_smart_string_function)(smart_string *buf, const char *format, va_list ap);
190190
void (*printf_to_smart_str_function)(smart_str *buf, const char *format, va_list ap);
191191
char *(*getenv_function)(char *name, size_t name_len);
192-
zend_string *(*resolve_path_function)(const char *filename, int filename_len);
192+
zend_string *(*resolve_path_function)(const char *filename, size_t filename_len);
193193
} zend_utility_functions;
194194

195195
typedef struct _zend_utility_values {
@@ -269,7 +269,7 @@ extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file
269269
extern void (*zend_printf_to_smart_string)(smart_string *buf, const char *format, va_list ap);
270270
extern void (*zend_printf_to_smart_str)(smart_str *buf, const char *format, va_list ap);
271271
extern ZEND_API char *(*zend_getenv)(char *name, size_t name_len);
272-
extern ZEND_API zend_string *(*zend_resolve_path)(const char *filename, int filename_len);
272+
extern ZEND_API zend_string *(*zend_resolve_path)(const char *filename, size_t filename_len);
273273

274274
ZEND_API ZEND_COLD void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
275275
ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);

Zend/zend_execute.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2780,7 +2780,7 @@ static zend_never_inline zend_op_array* ZEND_FASTCALL zend_include_or_eval(zval
27802780
zend_file_handle file_handle;
27812781
zend_string *resolved_path;
27822782

2783-
resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), (int)Z_STRLEN_P(inc_filename));
2783+
resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename));
27842784
if (resolved_path) {
27852785
if (zend_hash_exists(&EG(included_files), resolved_path)) {
27862786
goto already_compiled;

0 commit comments

Comments
 (0)