fix possible pointer truncation on win64

This commit is contained in:
Anatol Belski 2016-03-01 10:51:55 +01:00
parent afcce5ceca
commit acbbe76d7b

View file

@ -4259,7 +4259,7 @@ PHP_FUNCTION(imap_mime_header_decode)
zval myobject;
zend_string *str;
char *string, *charset, encoding, *text, *decode;
long charset_token, encoding_token, end_token, end, offset=0, i;
zend_long charset_token, encoding_token, end_token, end, offset=0, i;
unsigned long newlength;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &str) == FAILURE) {
@ -4274,8 +4274,8 @@ PHP_FUNCTION(imap_mime_header_decode)
charset = (char *) safe_emalloc((end + 1), 2, 0);
text = &charset[end + 1];
while (offset < end) { /* Reached end of the string? */
if ((charset_token = (long)php_memnstr(&string[offset], "=?", 2, string + end))) { /* Is there anything encoded in the string? */
charset_token -= (long)string;
if ((charset_token = (zend_long)php_memnstr(&string[offset], "=?", 2, string + end))) { /* Is there anything encoded in the string? */
charset_token -= (zend_long)string;
if (offset != charset_token) { /* Is there anything before the encoded data? */
/* Retrieve unencoded data that is found before encoded data */
memcpy(text, &string[offset], charset_token-offset);
@ -4285,10 +4285,10 @@ PHP_FUNCTION(imap_mime_header_decode)
add_property_string(&myobject, "text", text);
zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &myobject);
}
if ((encoding_token = (long)php_memnstr(&string[charset_token+2], "?", 1, string+end))) { /* Find token for encoding */
encoding_token -= (long)string;
if ((end_token = (long)php_memnstr(&string[encoding_token+3], "?=", 2, string+end))) { /* Find token for end of encoded data */
end_token -= (long)string;
if ((encoding_token = (zend_long)php_memnstr(&string[charset_token+2], "?", 1, string+end))) { /* Find token for encoding */
encoding_token -= (zend_long)string;
if ((end_token = (zend_long)php_memnstr(&string[encoding_token+3], "?=", 2, string+end))) { /* Find token for end of encoded data */
end_token -= (zend_long)string;
memcpy(charset, &string[charset_token + 2], encoding_token - (charset_token + 2)); /* Extract charset encoding */
charset[encoding_token-(charset_token + 2)] = 0x00;
encoding=string[encoding_token + 1]; /* Extract encoding from string */
@ -4797,7 +4797,7 @@ PHP_FUNCTION(imap_timeout)
break;
}
timeout = (long) mail_parameters(NIL, timeout_type, NIL);
timeout = (zend_long) mail_parameters(NIL, timeout_type, NIL);
RETURN_LONG(timeout);
} else if (timeout >= 0) {
switch (ttype) {
@ -4818,7 +4818,7 @@ PHP_FUNCTION(imap_timeout)
break;
}
timeout = (long) mail_parameters(NIL, timeout_type, (void *) timeout);
timeout = (zend_long) mail_parameters(NIL, timeout_type, (void *) timeout);
RETURN_TRUE;
} else {
RETURN_FALSE;