Skip to content

Commit 1c9bd51

Browse files
cmb69smalyshev
authored andcommitted
Fix #78875: Long filenames cause OOM and temp files are not cleaned
We must not cast `size_t` to `int` (unless the `size_t` value is guaranteed to be less than or equal to `INT_MAX`). In this case we can declare `array_len` as `size_t` in the first place.
1 parent bef96b9 commit 1c9bd51

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

main/rfc1867.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,8 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
692692
char *boundary, *s = NULL, *boundary_end = NULL, *start_arr = NULL, *array_index = NULL;
693693
char *lbuf = NULL, *abuf = NULL;
694694
zend_string *temp_filename = NULL;
695-
int boundary_len = 0, cancel_upload = 0, is_arr_upload = 0, array_len = 0;
695+
int boundary_len = 0, cancel_upload = 0, is_arr_upload = 0;
696+
size_t array_len = 0;
696697
int64_t total_bytes = 0, max_file_size = 0;
697698
int skip_upload = 0, anonindex = 0, is_anonymous;
698699
HashTable *uploaded_files = NULL;
@@ -1126,7 +1127,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
11261127
is_arr_upload = (start_arr = strchr(param,'[')) && (param[strlen(param)-1] == ']');
11271128

11281129
if (is_arr_upload) {
1129-
array_len = (int)strlen(start_arr);
1130+
array_len = strlen(start_arr);
11301131
if (array_index) {
11311132
efree(array_index);
11321133
}

0 commit comments

Comments
 (0)