diff options
| author | Stanislav Malyshev <stas@php.net> | 2016-09-25 16:07:14 -0700 |
|---|---|---|
| committer | Stanislav Malyshev <stas@php.net> | 2016-09-25 16:07:14 -0700 |
| commit | e1709b7e588cbda71c577f6e5b701713d0c70a23 (patch) | |
| tree | 1da4ffd1808a651cf64d8b17e67e9c679dd35986 | |
| parent | 33a8af0510c5899cbf9148f53da08cf4f2df0013 (diff) | |
| download | php-git-e1709b7e588cbda71c577f6e5b701713d0c70a23.tar.gz | |
Fix bug #73082
| -rw-r--r-- | ext/mbstring/mbstring.c | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index 56f7cfaa3e..cf5f8ed423 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -213,7 +213,7 @@ static const struct mb_overload_def mb_ovld[] = { {MB_OVERLOAD_REGEX, "split", "mb_split", "mb_orig_split"}, #endif {0, NULL, NULL, NULL} -}; +}; /* }}} */ /* {{{ arginfo */ @@ -648,7 +648,7 @@ static void *_php_mb_allocators_calloc(unsigned int nelems, unsigned int szelem) static void _php_mb_allocators_free(void *ptr) { efree(ptr); -} +} static void *_php_mb_allocators_pmalloc(unsigned int sz) { @@ -663,7 +663,7 @@ static void *_php_mb_allocators_prealloc(void *ptr, unsigned int sz) static void _php_mb_allocators_pfree(void *ptr) { pefree(ptr, 1); -} +} static mbfl_allocators _php_mb_allocators = { _php_mb_allocators_malloc, @@ -686,7 +686,7 @@ static sapi_post_entry mbstr_post_entries[] = { /* {{{ static int php_mb_parse_encoding_list() * Return 0 if input contains any illegal encoding, otherwise 1. - * Even if any illegal encoding is detected the result may contain a list + * Even if any illegal encoding is detected the result may contain a list * of parsed encodings. */ static int @@ -805,7 +805,7 @@ php_mb_parse_encoding_list(const char *value, size_t value_length, const mbfl_en /* {{{ static int php_mb_parse_encoding_array() * Return 0 if input contains any illegal encoding, otherwise 1. - * Even if any illegal encoding is detected the result may contain a list + * Even if any illegal encoding is detected the result may contain a list * of parsed encodings. */ static int @@ -960,7 +960,7 @@ static size_t php_mb_zend_encoding_converter(unsigned char **to, size_t *to_leng if (!mbfl_buffer_converter_result(convd, &result)) { mbfl_buffer_converter_delete(convd); return (size_t)-1; - } + } *to = result.val; *to_length = result.len; @@ -1192,7 +1192,7 @@ static char *php_mb_rfc1867_basename(const zend_encoding *encoding, char *filena * to nill or problem is fixed this code must remain enabled for all systems. */ s = php_mb_safe_strrchr_ex(filename, '\\', filename_len, (const mbfl_encoding *)encoding); s2 = php_mb_safe_strrchr_ex(filename, '/', filename_len, (const mbfl_encoding *)encoding); - + if (s && s2) { if (s > s2) { return ++s; @@ -1476,13 +1476,13 @@ PHP_INI_BEGIN() PHP_INI_ENTRY("mbstring.http_output", NULL, PHP_INI_ALL, OnUpdate_mbstring_http_output) STD_PHP_INI_ENTRY("mbstring.internal_encoding", NULL, PHP_INI_ALL, OnUpdate_mbstring_internal_encoding, internal_encoding_name, zend_mbstring_globals, mbstring_globals) PHP_INI_ENTRY("mbstring.substitute_character", NULL, PHP_INI_ALL, OnUpdate_mbstring_substitute_character) - STD_PHP_INI_ENTRY("mbstring.func_overload", "0", + STD_PHP_INI_ENTRY("mbstring.func_overload", "0", PHP_INI_SYSTEM, OnUpdateLong, func_overload, zend_mbstring_globals, mbstring_globals) STD_PHP_INI_BOOLEAN("mbstring.encoding_translation", "0", PHP_INI_SYSTEM | PHP_INI_PERDIR, - OnUpdate_mbstring_encoding_translation, - encoding_translation, zend_mbstring_globals, mbstring_globals) + OnUpdate_mbstring_encoding_translation, + encoding_translation, zend_mbstring_globals, mbstring_globals) PHP_INI_ENTRY("mbstring.http_output_conv_mimetypes", "^(text/|application/xhtml\\+xml)", PHP_INI_ALL, @@ -1624,21 +1624,21 @@ PHP_RINIT_FUNCTION(mbstring) /* override original function. */ if (MBSTRG(func_overload)){ p = &(mb_ovld[0]); - + while (p->type > 0) { - if ((MBSTRG(func_overload) & p->type) == p->type && + if ((MBSTRG(func_overload) & p->type) == p->type && zend_hash_find(EG(function_table), p->save_func, strlen(p->save_func)+1, (void **)&orig) != SUCCESS) { zend_hash_find(EG(function_table), p->ovld_func, strlen(p->ovld_func)+1 , (void **)&func); - + if (zend_hash_find(EG(function_table), p->orig_func, strlen(p->orig_func)+1, (void **)&orig) != SUCCESS) { php_error_docref("ref.mbstring" TSRMLS_CC, E_WARNING, "mbstring couldn't find function %s.", p->orig_func); return FAILURE; } else { zend_hash_add(EG(function_table), p->save_func, strlen(p->save_func)+1, orig, sizeof(zend_function), NULL); - if (zend_hash_update(EG(function_table), p->orig_func, strlen(p->orig_func)+1, func, sizeof(zend_function), + if (zend_hash_update(EG(function_table), p->orig_func, strlen(p->orig_func)+1, func, sizeof(zend_function), NULL) == FAILURE) { php_error_docref("ref.mbstring" TSRMLS_CC, E_WARNING, "mbstring couldn't replace function %s.", p->orig_func); return FAILURE; @@ -1685,10 +1685,10 @@ PHP_RSHUTDOWN_FUNCTION(mbstring) if (MBSTRG(func_overload)){ p = &(mb_ovld[0]); while (p->type > 0) { - if ((MBSTRG(func_overload) & p->type) == p->type && + if ((MBSTRG(func_overload) & p->type) == p->type && zend_hash_find(EG(function_table), p->save_func, strlen(p->save_func)+1, (void **)&orig) == SUCCESS) { - + zend_hash_update(EG(function_table), p->orig_func, strlen(p->orig_func)+1, orig, sizeof(zend_function), NULL); zend_hash_del(EG(function_table), p->save_func, strlen(p->save_func)+1); } @@ -1710,7 +1710,7 @@ PHP_MINFO_FUNCTION(mbstring) php_info_print_table_start(); php_info_print_table_row(2, "Multibyte Support", "enabled"); php_info_print_table_row(2, "Multibyte string engine", "libmbfl"); - php_info_print_table_row(2, "HTTP input encoding translation", MBSTRG(encoding_translation) ? "enabled": "disabled"); + php_info_print_table_row(2, "HTTP input encoding translation", MBSTRG(encoding_translation) ? "enabled": "disabled"); { char tmp[256]; snprintf(tmp, sizeof(tmp), "%d.%d.%d", MBFL_VERSION_MAJOR, MBFL_VERSION_MINOR, MBFL_VERSION_TEENY); @@ -1846,7 +1846,7 @@ PHP_FUNCTION(mb_http_input) temp = list; spprintf(&list, 0, "%s,%s", temp, (*entry)->name); efree(temp); - if (!list) { + if (!list) { break; } } else { @@ -2078,12 +2078,12 @@ PHP_FUNCTION(mb_parse_str) encstr = estrndup(encstr, encstr_len); info.data_type = PARSE_STRING; - info.separator = PG(arg_separator).input; + info.separator = PG(arg_separator).input; info.report_errors = 1; info.to_encoding = MBSTRG(current_internal_encoding); info.to_language = MBSTRG(language); info.from_encodings = MBSTRG(http_input_list); - info.num_from_encodings = MBSTRG(http_input_list_size); + info.num_from_encodings = MBSTRG(http_input_list_size); info.from_language = MBSTRG(language); if (track_vars_array != NULL) { @@ -2093,8 +2093,8 @@ PHP_FUNCTION(mb_parse_str) if (!EG(active_symbol_table)) { zend_rebuild_symbol_table(TSRMLS_C); } - Z_ARRVAL(tmp) = EG(active_symbol_table); - detected = _php_mb_encoding_handler_ex(&info, &tmp, encstr TSRMLS_CC); + Z_ARRVAL(tmp) = EG(active_symbol_table); + detected = _php_mb_encoding_handler_ex(&info, &tmp, encstr TSRMLS_CC); } MBSTRG(http_input_identify) = detected; @@ -2158,7 +2158,7 @@ PHP_FUNCTION(mb_output_handler) if (SG(sapi_headers).send_default_content_type || send_text_mimetype) { charset = encoding->mime_name; if (charset) { - len = spprintf( &p, 0, "Content-Type: %s; charset=%s", mimetype, charset ); + len = spprintf( &p, 0, "Content-Type: %s; charset=%s", mimetype, charset ); if (sapi_add_header(p, len, 0) != FAILURE) { SG(sapi_headers).send_default_content_type = 0; } @@ -2181,7 +2181,7 @@ PHP_FUNCTION(mb_output_handler) /* mode */ mbfl_buffer_converter_illegal_mode(MBSTRG(outconv), MBSTRG(current_filter_illegal_mode)); mbfl_buffer_converter_illegal_substchar(MBSTRG(outconv), MBSTRG(current_filter_illegal_substchar)); - + /* feed the string */ mbfl_string_init(&string); /* these are not needed. convd has encoding info. @@ -2193,11 +2193,11 @@ PHP_FUNCTION(mb_output_handler) mbfl_buffer_converter_feed(MBSTRG(outconv), &string); if (last_feed) { mbfl_buffer_converter_flush(MBSTRG(outconv)); - } + } /* get the converter output, and return it */ mbfl_buffer_converter_result(MBSTRG(outconv), &result); RETVAL_STRINGL((char *)result.val, result.len, 0); /* the string is already strdup()'ed */ - + /* delete the converter if it is the last feed. */ if (last_feed) { MBSTRG(illegalchars) += mbfl_buffer_illegalchars(MBSTRG(outconv)); @@ -3156,7 +3156,7 @@ PHP_FUNCTION(mb_convert_case) if (newstr) { RETVAL_STRINGL(newstr, ret_len, 0); - } + } } /* }}} */ @@ -3380,7 +3380,7 @@ PHP_FUNCTION(mb_encode_mimeheader) mbfl_string_init(&result); ret = mbfl_mime_header_encode(&string, &result, charset, transenc, linefeed, indent); if (ret != NULL) { - RETVAL_STRINGL((char *)ret->val, ret->len, 0); /* the string is already strdup()'ed */ + RETVAL_STRINGL_CHECK((char *)ret->val, ret->len, 0); /* the string is already strdup()'ed */ } else { RETVAL_FALSE; } @@ -3507,7 +3507,7 @@ PHP_FUNCTION(mb_convert_kana) ret = mbfl_ja_jp_hantozen(&string, &result, opt); if (ret != NULL) { - RETVAL_STRINGL((char *)ret->val, ret->len, 0); /* the string is already strdup()'ed */ + RETVAL_STRINGL_CHECK((char *)ret->val, ret->len, 0); /* the string is already strdup()'ed */ } else { RETVAL_FALSE; } @@ -3841,7 +3841,7 @@ php_mb_numericentity_exec(INTERNAL_FUNCTION_PARAMETERS, int type) ret = mbfl_html_numeric_entity(&string, &result, convmap, mapsize, type); if (ret != NULL) { - RETVAL_STRINGL((char *)ret->val, ret->len, 0); + RETVAL_STRINGL_CHECK((char *)ret->val, ret->len, 0); } else { RETVAL_FALSE; } @@ -3929,12 +3929,12 @@ static int _php_mbstr_parse_mail_headers(HashTable *ht, const char *str, size_t /* * C o n t e n t - T y p e : t e x t / h t m l \r\n - * ^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^ ^^^^ - * state 0 1 2 3 + * ^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^ ^^^^ + * state 0 1 2 3 * * C o n t e n t - T y p e : t e x t / h t m l \r\n - * ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ - * crlf_state -1 0 1 -1 + * ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ + * crlf_state -1 0 1 -1 * */ @@ -4000,7 +4000,7 @@ static int _php_mbstr_parse_mail_headers(HashTable *ht, const char *str, size_t token.a = 0; state = 1; break; - + case 2: if (crlf_state != -1) { token.c = (char *)ps; @@ -4177,14 +4177,14 @@ PHP_FUNCTION(mb_send_mail) if ((param_name = php_strtok_r(p, "= ", &tmp)) != NULL) { if (strcasecmp(param_name, "charset") == 0) { enum mbfl_no_encoding _tran_cs = tran_cs; - + charset = php_strtok_r(NULL, "= \"", &tmp); if (charset != NULL) { _tran_cs = mbfl_name2no_encoding(charset); } if (_tran_cs == mbfl_no_encoding_invalid) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported charset \"%s\" - will be regarded as ascii", charset); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported charset \"%s\" - will be regarded as ascii", charset); _tran_cs = mbfl_no_encoding_ascii; } tran_cs = _tran_cs; @@ -4209,7 +4209,7 @@ PHP_FUNCTION(mb_send_mail) break; default: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported transfer encoding \"%s\" - will be regarded as 8bit", s->c); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported transfer encoding \"%s\" - will be regarded as 8bit", s->c); body_enc = mbfl_no_encoding_8bit; break; } @@ -4342,7 +4342,7 @@ PHP_FUNCTION(mb_send_mail) extra_cmd = php_escape_shell_cmd(force_extra_parameters); } else if (extra_cmd) { extra_cmd = php_escape_shell_cmd(extra_cmd); - } + } if (!err && php_mail(to_r, subject, message, headers, extra_cmd TSRMLS_CC)) { RETVAL_TRUE; @@ -4441,7 +4441,7 @@ PHP_FUNCTION(mb_get_info) } if ((name = (char *)mbfl_no_language2name(MBSTRG(language))) != NULL) { add_assoc_string(return_value, "language", name, 1); - } + } n = MBSTRG(current_detect_order_list_size); entry = MBSTRG(current_detect_order_list); if (n > 0) { @@ -4471,15 +4471,15 @@ PHP_FUNCTION(mb_get_info) } else if (!strcasecmp("internal_encoding", typ)) { if (MBSTRG(current_internal_encoding)) { RETVAL_STRING((char *)MBSTRG(current_internal_encoding)->name, 1); - } + } } else if (!strcasecmp("http_input", typ)) { if (MBSTRG(http_input_identify)) { RETVAL_STRING((char *)MBSTRG(http_input_identify)->name, 1); - } + } } else if (!strcasecmp("http_output", typ)) { if (MBSTRG(current_http_output_encoding)) { RETVAL_STRING((char *)MBSTRG(current_http_output_encoding)->name, 1); - } + } } else if (!strcasecmp("http_output_conv_mimetypes", typ)) { if ((name = (char *)zend_ini_string("mbstring.http_output_conv_mimetypes", sizeof("mbstring.http_output_conv_mimetypes"), 0)) != NULL) { RETVAL_STRING(name, 1); @@ -4522,7 +4522,7 @@ PHP_FUNCTION(mb_get_info) } else if (!strcasecmp("language", typ)) { if ((name = (char *)mbfl_no_language2name(MBSTRG(language))) != NULL) { RETVAL_STRING(name, 1); - } + } } else if (!strcasecmp("detect_order", typ)) { n = MBSTRG(current_detect_order_list_size); entry = MBSTRG(current_detect_order_list); @@ -4589,9 +4589,9 @@ PHP_FUNCTION(mb_check_encoding) if (convd == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create converter"); RETURN_FALSE; - } + } mbfl_buffer_converter_illegal_mode(convd, MBFL_OUTPUTFILTER_ILLEGAL_MODE_NONE); - mbfl_buffer_converter_illegal_substchar(convd, 0); + mbfl_buffer_converter_illegal_substchar(convd, 0); /* initialize string */ mbfl_string_init_set(&string, mbfl_no_language_neutral, encoding->no_encoding); @@ -4642,7 +4642,7 @@ static void php_mb_populate_current_detect_order_list(TSRMLS_D) } /* {{{ static int php_mb_encoding_translation() */ -static int php_mb_encoding_translation(TSRMLS_D) +static int php_mb_encoding_translation(TSRMLS_D) { return MBSTRG(encoding_translation); } @@ -4768,7 +4768,7 @@ MBSTRING_API int php_mb_stripos(int mode, const char *old_haystack, unsigned int { int haystack_char_len = mbfl_strlen(&haystack); - + if (mode) { if ((offset > 0 && offset > haystack_char_len) || (offset < 0 && -offset > haystack_char_len)) { |
