Skip to content

Commit c71416c

Browse files
committed
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. (cherry picked from commit 1c9bd51)
1 parent 47a2da6 commit c71416c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ PHP NEWS
33
14 May 2020, PHP 7.3.18
44

55
- Core:
6+
. Fixed bug #78875 (Long filenames cause OOM and temp files are not cleaned).
7+
(CVE-2019-11048) (cmb)
68
. Fixed bug #79434 (PHP 7.3 and PHP-7.4 crash with NULL-pointer dereference
79
on !CS constant). (Nikita)
810
. Fixed bug #79477 (casting object into array creates references). (Nikita)

main/rfc1867.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,8 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
690690
char *boundary, *s = NULL, *boundary_end = NULL, *start_arr = NULL, *array_index = NULL;
691691
char *lbuf = NULL, *abuf = NULL;
692692
zend_string *temp_filename = NULL;
693-
int boundary_len = 0, cancel_upload = 0, is_arr_upload = 0, array_len = 0;
693+
int boundary_len = 0, cancel_upload = 0, is_arr_upload = 0;
694+
size_t array_len = 0;
694695
int64_t total_bytes = 0, max_file_size = 0;
695696
int skip_upload = 0, anonindex = 0, is_anonymous;
696697
HashTable *uploaded_files = NULL;
@@ -1124,7 +1125,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
11241125
is_arr_upload = (start_arr = strchr(param,'[')) && (param[strlen(param)-1] == ']');
11251126

11261127
if (is_arr_upload) {
1127-
array_len = (int)strlen(start_arr);
1128+
array_len = strlen(start_arr);
11281129
if (array_index) {
11291130
efree(array_index);
11301131
}

0 commit comments

Comments
 (0)