@@ -3631,10 +3631,16 @@ PHP_FUNCTION(imap_mail_compose)
3631
3631
topbod = bod ;
3632
3632
3633
3633
if ((pvalue = zend_hash_str_find (Z_ARRVAL_P (data ), "type" , sizeof ("type" ) - 1 )) != NULL ) {
3634
- bod -> type = (short ) zval_get_long (pvalue );
3634
+ zend_long type = zval_get_long (pvalue );
3635
+ if (type >= 0 && type <= TYPEMAX && body_types [type ] != NULL ) {
3636
+ bod -> type = (short ) type ;
3637
+ }
3635
3638
}
3636
3639
if ((pvalue = zend_hash_str_find (Z_ARRVAL_P (data ), "encoding" , sizeof ("encoding" ) - 1 )) != NULL ) {
3637
- bod -> encoding = (short ) zval_get_long (pvalue );
3640
+ zend_long encoding = zval_get_long (pvalue );
3641
+ if (encoding >= 0 && encoding <= ENCMAX && body_encodings [encoding ] != NULL ) {
3642
+ bod -> encoding = (short ) encoding ;
3643
+ }
3638
3644
}
3639
3645
if ((pvalue = zend_hash_str_find (Z_ARRVAL_P (data ), "charset" , sizeof ("charset" ) - 1 )) != NULL ) {
3640
3646
convert_to_string_ex (pvalue );
@@ -3716,10 +3722,13 @@ PHP_FUNCTION(imap_mail_compose)
3716
3722
bod -> md5 = cpystr (Z_STRVAL_P (pvalue ));
3717
3723
}
3718
3724
} else if (Z_TYPE_P (data ) == IS_ARRAY && topbod -> type == TYPEMULTIPART ) {
3719
- short type = -1 ;
3725
+ short type = 0 ;
3720
3726
SEPARATE_ARRAY (data );
3721
3727
if ((pvalue = zend_hash_str_find (Z_ARRVAL_P (data ), "type" , sizeof ("type" ) - 1 )) != NULL ) {
3722
- type = (short ) zval_get_long (pvalue );
3728
+ zend_long tmp_type = zval_get_long (pvalue );
3729
+ if (tmp_type >= 0 && tmp_type <= TYPEMAX && tmp_type != TYPEMULTIPART && body_types [tmp_type ] != NULL ) {
3730
+ type = (short ) tmp_type ;
3731
+ }
3723
3732
}
3724
3733
3725
3734
if (!toppart ) {
@@ -3732,13 +3741,13 @@ PHP_FUNCTION(imap_mail_compose)
3732
3741
}
3733
3742
3734
3743
bod = & mypart -> body ;
3735
-
3736
- if (type != TYPEMULTIPART ) {
3737
- bod -> type = type ;
3738
- }
3744
+ bod -> type = type ;
3739
3745
3740
3746
if ((pvalue = zend_hash_str_find (Z_ARRVAL_P (data ), "encoding" , sizeof ("encoding" ) - 1 )) != NULL ) {
3741
- bod -> encoding = (short ) zval_get_long (pvalue );
3747
+ zend_long encoding = zval_get_long (pvalue );
3748
+ if (encoding >= 0 && encoding <= ENCMAX && body_encodings [encoding ] != NULL ) {
3749
+ bod -> encoding = (short ) encoding ;
3750
+ }
3742
3751
}
3743
3752
if ((pvalue = zend_hash_str_find (Z_ARRVAL_P (data ), "charset" , sizeof ("charset" ) - 1 )) != NULL ) {
3744
3753
convert_to_string_ex (pvalue );
0 commit comments