@@ -3643,10 +3643,16 @@ PHP_FUNCTION(imap_mail_compose)
3643
3643
topbod = bod ;
3644
3644
3645
3645
if ((pvalue = zend_hash_str_find (Z_ARRVAL_P (data ), "type" , sizeof ("type" ) - 1 )) != NULL ) {
3646
- bod -> type = (short ) zval_get_long (pvalue );
3646
+ zend_long type = zval_get_long (pvalue );
3647
+ if (type >= 0 && type <= TYPEMAX && body_types [type ] != NULL ) {
3648
+ bod -> type = (short ) type ;
3649
+ }
3647
3650
}
3648
3651
if ((pvalue = zend_hash_str_find (Z_ARRVAL_P (data ), "encoding" , sizeof ("encoding" ) - 1 )) != NULL ) {
3649
- bod -> encoding = (short ) zval_get_long (pvalue );
3652
+ zend_long encoding = zval_get_long (pvalue );
3653
+ if (encoding >= 0 && encoding <= ENCMAX && body_encodings [encoding ] != NULL ) {
3654
+ bod -> encoding = (short ) encoding ;
3655
+ }
3650
3656
}
3651
3657
if ((pvalue = zend_hash_str_find (Z_ARRVAL_P (data ), "charset" , sizeof ("charset" ) - 1 )) != NULL ) {
3652
3658
convert_to_string_ex (pvalue );
@@ -3728,10 +3734,13 @@ PHP_FUNCTION(imap_mail_compose)
3728
3734
bod -> md5 = cpystr (Z_STRVAL_P (pvalue ));
3729
3735
}
3730
3736
} else if (Z_TYPE_P (data ) == IS_ARRAY && topbod -> type == TYPEMULTIPART ) {
3731
- short type = -1 ;
3737
+ short type = 0 ;
3732
3738
SEPARATE_ARRAY (data );
3733
3739
if ((pvalue = zend_hash_str_find (Z_ARRVAL_P (data ), "type" , sizeof ("type" ) - 1 )) != NULL ) {
3734
- type = (short ) zval_get_long (pvalue );
3740
+ zend_long tmp_type = zval_get_long (pvalue );
3741
+ if (tmp_type >= 0 && tmp_type <= TYPEMAX && tmp_type != TYPEMULTIPART && body_types [tmp_type ] != NULL ) {
3742
+ type = (short ) tmp_type ;
3743
+ }
3735
3744
}
3736
3745
3737
3746
if (!toppart ) {
@@ -3744,13 +3753,13 @@ PHP_FUNCTION(imap_mail_compose)
3744
3753
}
3745
3754
3746
3755
bod = & mypart -> body ;
3747
-
3748
- if (type != TYPEMULTIPART ) {
3749
- bod -> type = type ;
3750
- }
3756
+ bod -> type = type ;
3751
3757
3752
3758
if ((pvalue = zend_hash_str_find (Z_ARRVAL_P (data ), "encoding" , sizeof ("encoding" ) - 1 )) != NULL ) {
3753
- bod -> encoding = (short ) zval_get_long (pvalue );
3759
+ zend_long encoding = zval_get_long (pvalue );
3760
+ if (encoding >= 0 && encoding <= ENCMAX && body_encodings [encoding ] != NULL ) {
3761
+ bod -> encoding = (short ) encoding ;
3762
+ }
3754
3763
}
3755
3764
if ((pvalue = zend_hash_str_find (Z_ARRVAL_P (data ), "charset" , sizeof ("charset" ) - 1 )) != NULL ) {
3756
3765
convert_to_string_ex (pvalue );
0 commit comments