Skip to content

Fix crashes with entity references and predefined entities #13004

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
wants to merge 2 commits into from

Conversation

nielsdos
Copy link
Member

There's two issues here:

  • freeing of predefined entity declaration crashes (unique to 8.3 & master)
  • using multiple entity references for a single entity declaration crashes (since forever)

The fix for the last issue is fairly easy to do on 8.3, but may require a slightly different approach on 8.2. Therefore, for now this is 8.3-only.

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sensible to me

@nielsdos nielsdos closed this in 3fa5af8 Dec 23, 2023
@nielsdos
Copy link
Member Author

Reopening. This doesn't work on libxml2 < 2.12.0 because the xmlFreeEntity API is not public...

@nielsdos nielsdos reopened this Dec 23, 2023
@nielsdos nielsdos requested a review from Girgias January 15, 2024 21:34
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me

case XML_ENTITY_REF_NODE:
/* Entity reference nodes are special: their children point to entity declarations,
* but they don't own the declarations and therefore shouldn't free the children.
* Moreover, there can be N>1 reference nodes for a single entity declarations. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The N>1 could potentially cause confusing here? Not sure what better wording is possible tho.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix:

Suggested change
* Moreover, there can be N>1 reference nodes for a single entity declarations. */
* Moreover, there can be more than one reference node for a single entity declarations. */

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suggestion looks good, thank you!

Comment on lines +211 to +213
#if LIBXML_VERSION >= 21200
xmlFreeEntity(entity);
#else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it is unlikely that the extension is compiled against the newer version and an older libxml version is used at runtime.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be not done, that's generally always a bad idea for libraries.

@nielsdos nielsdos closed this in 120bd36 Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants