diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2004-06-24 14:17:03 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2004-06-24 14:17:03 +0000 |
commit | 1da45c2873d59fffc6535010b168824b2af5db67 (patch) | |
tree | d4f0d72ee700f91888b7814a1644376df2100c8d | |
parent | 7de1333bb208de60c44fc6931d6ff0f9dda6507a (diff) | |
download | php-git-1da45c2873d59fffc6535010b168824b2af5db67.tar.gz |
Fixed bug #1713 (possible crash inside tidy_get_error_buffer()).
-rw-r--r-- | ext/tidy/tidy.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 3ef3dc5866..09ea630c07 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -44,6 +44,8 @@ if ((PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR RETURN_FALSE; \ } \ +#define TIDY_CLEAR_ERROR if (TG(tdoc)->errbuf && TG(tdoc)->errbuf->bp) { tidyBufClear(TG(tdoc)->errbuf); } + function_entry tidy_functions[] = { PHP_FE(tidy_setopt, NULL) PHP_FE(tidy_getopt, NULL) @@ -255,6 +257,9 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_fil } else { data = arg1; } + + TIDY_CLEAR_ERROR; + if (cfg) { if(Z_TYPE_P(cfg) == IS_ARRAY) { char *opt_name = NULL; @@ -341,6 +346,9 @@ PHP_RINIT_FUNCTION(tidy) } TG(used) = 1; } + + TIDY_CLEAR_ERROR; + return SUCCESS; } @@ -394,6 +402,8 @@ PHP_FUNCTION(tidy_parse_string) RETURN_FALSE; } + TIDY_CLEAR_ERROR; + if(tidyParseString(TG(tdoc)->doc, input) < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "[Tidy error] %s", TG(tdoc)->errbuf->bp); RETURN_FALSE; @@ -419,7 +429,9 @@ PHP_FUNCTION(tidy_get_error_buffer) if (detailed) { tidyErrorSummary(TG(tdoc)->doc); } - + if (!TG(tdoc)->errbuf || !TG(tdoc)->errbuf->bp) { + RETURN_FALSE; + } RETVAL_STRING(TG(tdoc)->errbuf->bp, 1); tidyBufClear(TG(tdoc)->errbuf); } @@ -461,7 +473,9 @@ PHP_FUNCTION(tidy_parse_file) if (!(contents = php_tidy_file_to_mem(inputfile, use_include_path TSRMLS_CC))) { RETURN_FALSE; } - + + TIDY_CLEAR_ERROR; + if(tidyParseString(TG(tdoc)->doc, contents) < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "[Tidy error] %s", TG(tdoc)->errbuf->bp); RETVAL_FALSE; |