Skip to content
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

Fix strdup for LibXML: undefined behavior #5587

Merged
merged 1 commit into from Jan 14, 2018

Conversation

lbguilherme
Copy link
Contributor

The last argument of xmlGcMemSetup is a GC-aware implementation of strdup. It should return a valid C-string with the null-character.

This most likely is causing a buffer overflow condition inside libxml, because it might treat the return of this function as a null-terminated string, and it was not. This change is hard to spec.

For reference, here is strdup from glibc: https://gist.github.com/reagent/3758387

The last argument of xmlGcMemSetup is a GC-aware implementation of strdup. It should return a valid C-string with the null-character.
Copy link
Member

@asterite asterite left a comment

Choose a reason for hiding this comment

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

Good catch!

@asterite asterite merged commit b4fed51 into crystal-lang:master Jan 14, 2018
@RX14 RX14 added this to the Next milestone Jan 14, 2018
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.

None yet

3 participants