Skip to content

Fix #61557: CGI/FPM process could crash when using libxml #194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix #61557: CGI/FPM process could crash when using libxml
Since d8bddb9 some SAPI would only
setup/reset callbacks to libxml once, instead of for each request
processed. However, this also included a callback for structured
errors, which should remain per request (as it can be defined through
PHP's libxml_use_internal_errors).

As a result, after the internal handler was set in a request,
processing another request would result in the handler being triggered
while the memory associated with it (LIBXML(error_list)) had been
free-d/reset, leading to the process segfaulting.

This reset the handler for structured errors after each request.

(Bug #61325 might possibly also be the same bug)
  • Loading branch information
jjacky committed Sep 13, 2012
commit 36282040d21fa3003444269f3a49a3ae11814eb2
3 changes: 1 addition & 2 deletions ext/libxml/libxml.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,6 @@ static PHP_MSHUTDOWN_FUNCTION(libxml)
{
if (!_php_libxml_per_request_initialization) {
xmlSetGenericErrorFunc(NULL, NULL);
xmlSetStructuredErrorFunc(NULL, NULL);

xmlParserInputBufferCreateFilenameDefault(NULL);
xmlOutputBufferCreateFilenameDefault(NULL);
Expand All @@ -876,11 +875,11 @@ static int php_libxml_post_deactivate()
/* reset libxml generic error handling */
if (_php_libxml_per_request_initialization) {
xmlSetGenericErrorFunc(NULL, NULL);
xmlSetStructuredErrorFunc(NULL, NULL);

xmlParserInputBufferCreateFilenameDefault(NULL);
xmlOutputBufferCreateFilenameDefault(NULL);
}
xmlSetStructuredErrorFunc(NULL, NULL);

if (LIBXML(stream_context)) {
/* the steam_context resource will be released by resource list destructor */
Expand Down