@@ -577,6 +577,11 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_fil
577
577
data = arg1 ;
578
578
}
579
579
580
+ if (ZEND_SIZE_T_UINT_OVFL (ZSTR_LEN (data ))) {
581
+ php_error_docref (NULL , E_WARNING , "Input string is too long" );
582
+ RETURN_FALSE ;
583
+ }
584
+
580
585
doc = tidyCreate ();
581
586
errbuf = emalloc (sizeof (TidyBuffer ));
582
587
tidyBufInit (errbuf );
@@ -608,7 +613,7 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_fil
608
613
TidyBuffer buf ;
609
614
610
615
tidyBufInit (& buf );
611
- tidyBufAttach (& buf , (byte * ) ZSTR_VAL (data ), ZSTR_LEN (data ));
616
+ tidyBufAttach (& buf , (byte * ) ZSTR_VAL (data ), ( uint ) ZSTR_LEN (data ));
612
617
613
618
if (tidyParseBuffer (doc , & buf ) < 0 ) {
614
619
php_error_docref (NULL , E_WARNING , "%s" , errbuf -> bp );
@@ -1158,10 +1163,15 @@ static int php_tidy_output_handler(void **nothing, php_output_context *output_co
1158
1163
tidyOptSetBool (doc , TidyForceOutput , yes );
1159
1164
tidyOptSetBool (doc , TidyMark , no );
1160
1165
1166
+ if (ZEND_SIZE_T_UINT_OVFL (output_context -> in .used )) {
1167
+ php_error_docref (NULL , E_WARNING , "Input string is too long" );
1168
+ return status ;
1169
+ }
1170
+
1161
1171
TIDY_SET_DEFAULT_CONFIG (doc );
1162
1172
1163
1173
tidyBufInit (& inbuf );
1164
- tidyBufAttach (& inbuf , (byte * ) output_context -> in .data , output_context -> in .used );
1174
+ tidyBufAttach (& inbuf , (byte * ) output_context -> in .data , ( uint ) output_context -> in .used );
1165
1175
1166
1176
if (0 <= tidyParseBuffer (doc , & inbuf ) && 0 <= tidyCleanAndRepair (doc )) {
1167
1177
tidyBufInit (& outbuf );
@@ -1412,7 +1422,7 @@ static PHP_FUNCTION(tidy_get_config)
1412
1422
break ;
1413
1423
1414
1424
case TidyBoolean :
1415
- add_assoc_bool (return_value , opt_name , ( zend_long ) opt_value );
1425
+ add_assoc_bool (return_value , opt_name , opt_value ? 1 : 0 );
1416
1426
break ;
1417
1427
}
1418
1428
}
0 commit comments