File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -274,8 +274,13 @@ PHPAPI char *php_escape_shell_cmd(char *str)
274274 cmd = safe_emalloc (2 , l , 1 );
275275
276276 for (x = 0 , y = 0 ; x < l ; x ++ ) {
277+ int mb_len = php_mblen (str + x , (l - x ));
278+
277279 /* skip non-valid multibyte characters */
278- if (php_mblen (str + x , (l - x )) < 0 ) {
280+ if (mb_len < 0 ) {
281+ continue ;
282+ } else if (mb_len > 1 ) {
283+ x += mb_len - 1 ;
279284 continue ;
280285 }
281286
@@ -356,6 +361,16 @@ PHPAPI char *php_escape_shell_arg(char *str)
356361#endif
357362
358363 for (x = 0 ; x < l ; x ++ ) {
364+ int mb_len = php_mblen (str + x , (l - x ));
365+
366+ /* skip non-valid multibyte characters */
367+ if (mb_len < 0 ) {
368+ continue ;
369+ } else if (mb_len > 1 ) {
370+ x += mb_len - 1 ;
371+ continue ;
372+ }
373+
359374 switch (str [x ]) {
360375#ifdef PHP_WIN32
361376 case '"' :
You can’t perform that action at this time.
0 commit comments