Skip to content

Tidy 5.7.20 GetSurrogatePair can use uninitialised value processing malformed entity refs #798

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
dd8 opened this issue Jan 29, 2019 · 1 comment
Labels

Comments

@dd8
Copy link

dd8 commented Jan 29, 2019

GetSurrogatePair ignores scanf return value, which means ch may be uninitialised if buf doesn't contain hex or digits (or uses # incorrectly) leading to UTF encoding errors and undefined behaviour.

Here's a patch for the issue
patch-scanf.diff.txt

Compiles in XCode 10 clang on Mac, Visual Studio 2015 on Windows
Tested in production on macOS 10.13, macOS 10.14, Windows 7, Windows 10, Windows Server 2016

Not tested on Linux/gcc

@geoffmcl
Copy link
Contributor

@dd8 thank for the issue and the patch... will try to include it soon... maybe remind me if too long...

It is interesting, one of the issues mentioned in #788, 12074 I think, mentioned IsHighSurrogate, but was unable to repeat the bug... as usual, without being able to replicate, is very difficult to investigate... but maybe this is it? ...

But regardless of that, agree with your assessment, we ignore the scanf return, to our peril, thus the patch looks, logic-wise, good...

As stated, baring any negative comments, will try to include it soonest... thanks...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants