diff options
author | Rui Hirokawa <hirokawa@php.net> | 2006-03-21 01:58:27 +0000 |
---|---|---|
committer | Rui Hirokawa <hirokawa@php.net> | 2006-03-21 01:58:27 +0000 |
commit | 6912dab9ebf0107f3da0b74ef899c536091ece84 (patch) | |
tree | b42eabc5b8814bd9925cb5c9a8cdc31f3762da3e /ext/mbstring/mbstring.c | |
parent | 79e7432c971e904c84b7774674fc71f805091fd4 (diff) | |
download | php-git-6912dab9ebf0107f3da0b74ef899c536091ece84.tar.gz |
@added possible encoding attack detection by mb_get_info('illegalchars').
Diffstat (limited to 'ext/mbstring/mbstring.c')
-rw-r--r-- | ext/mbstring/mbstring.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index 06490d4dd4..86c620f4ff 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -927,6 +927,7 @@ PHP_RINIT_FUNCTION(mbstring) MBSTRG(current_http_output_encoding) = MBSTRG(http_output_encoding); MBSTRG(current_filter_illegal_mode) = MBSTRG(filter_illegal_mode); MBSTRG(current_filter_illegal_substchar) = MBSTRG(filter_illegal_substchar); + MBSTRG(illegalchars) = 0; n = 0; if (MBSTRG(detect_order_list)) { @@ -995,6 +996,7 @@ PHP_RSHUTDOWN_FUNCTION(mbstring) MBSTRG(current_detect_order_list_size) = 0; } if (MBSTRG(outconv) != NULL) { + MBSTRG(illegalchars) += mbfl_buffer_illegalchars(MBSTRG(outconv)); mbfl_buffer_converter_delete(MBSTRG(outconv)); MBSTRG(outconv) = NULL; } @@ -1451,6 +1453,7 @@ PHP_FUNCTION(mb_output_handler) if ((arg_status & PHP_OUTPUT_HANDLER_START) != 0) { /* delete the converter just in case. */ if (MBSTRG(outconv)) { + MBSTRG(illegalchars) += mbfl_buffer_illegalchars(MBSTRG(outconv)); mbfl_buffer_converter_delete(MBSTRG(outconv)); MBSTRG(outconv) = NULL; } @@ -1515,6 +1518,7 @@ PHP_FUNCTION(mb_output_handler) /* delete the converter if it is the last feed. */ if (last_feed) { + MBSTRG(illegalchars) += mbfl_buffer_illegalchars(MBSTRG(outconv)); mbfl_buffer_converter_delete(MBSTRG(outconv)); MBSTRG(outconv) = NULL; } @@ -2079,6 +2083,7 @@ MBSTRING_API char * php_mb_convert_encoding(char *input, size_t length, char *_t output = (char *)ret->val; } + MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd); mbfl_buffer_converter_delete(convd); return output; } @@ -2725,6 +2730,7 @@ detect_end: } efree(stack); + MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd); mbfl_buffer_converter_delete(convd); } @@ -3422,6 +3428,8 @@ PHP_FUNCTION(mb_get_info) if (lang != NULL && (name = (char *)mbfl_no_encoding2name(lang->mail_body_encoding)) != NULL) { RETVAL_STRING(name, 1); } + } else if (!strcasecmp("illegalchars", typ)) { + RETVAL_LONG(MBSTRG(illegalchars)); } else { RETURN_FALSE; } @@ -3588,6 +3596,7 @@ MBSTRING_API int php_mb_gpc_encoding_converter(char **str, int *len, int num, co str[i] = ret->val; len[i] = ret->len; } + MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd); mbfl_buffer_converter_delete(convd); } @@ -3804,6 +3813,7 @@ int php_mb_encoding_converter(char **to, int *to_length, const char *from, *to = ret->val; *to_length = ret->len; } + MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd); mbfl_buffer_converter_delete(convd); return ret ? 0 : -1; |