From acbbe76d7bbf15e15987bcf1ef29e0045e17764f Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 1 Mar 2016 10:51:55 +0100 Subject: [PATCH] fix possible pointer truncation on win64 --- ext/imap/php_imap.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index 3d60e9473d..766ea347d2 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -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; -- 2.40.0