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

escapes strings before generating OGRE document #891

Merged
merged 2 commits into from Oct 30, 2018

Conversation

Projects
None yet
2 participants
@gitoleg
Contributor

gitoleg commented Oct 29, 2018

fixes #890

Bap fails with a very nasty exception if the llvm backend produces an ogre document that can't be parsed due to an unexpected symbol sequence, e.g. parsing of the

(symbol-entry "?<Constant "Disconnecting; %d\r\n">" 0x9258 0x14 0x4a2d8) 

failed just because of ; symbol, which introduces a comment.

Previously, we tended to quote strings only if there are some suspicious characters inside.
Starting from this PR we will quote any string in ogre document and replace any suspicious character with its code. And suspicious is everything but letters and digits:

(symbol-entry "\x3f\x3cConstant\x20\x22Disconnecting\x3b\x20\x25d\x5cr\x5cn\x22\x3e" 0x9258 0x14 0x4a2d8)

Note, these changes will not affect an ogre dump readability:

(symbol-entry .text_45 46438 0 312806)
(symbol-entry .text_46 46484 0 312852)
(symbol-entry "?<Constant \"Disconnecting; %d\\r\\n\">" 37464 20 303832)
(symbol-entry "?<Constant \"mac.c\">" 37440 8 303808)
(symbol-entry "?<Constant \"macCtrl\">" 37448 8 303816)
(symbol-entry "?<Constant \"macMon\">" 37456 8 303824)
....

@gitoleg gitoleg changed the title from hardens a producing of ogre document in llvm backend to hardens the production of a ogre document in the llvm backend Oct 29, 2018

@gitoleg gitoleg changed the title from hardens the production of a ogre document in the llvm backend to hardens the production of an ogre document in the llvm backend Oct 29, 2018

@ivg ivg changed the title from hardens the production of an ogre document in the llvm backend to escapes string before generating OGRE document Oct 29, 2018

@ivg ivg changed the title from escapes string before generating OGRE document to escapes strings before generating OGRE document Oct 29, 2018

@ivg

This comment has been minimized.

Member

ivg commented Oct 29, 2018

The change is necessary but not sufficient. It is still possible that an OGRE document passed to BAP would not be well-formed, so on the ML side we shall handle all errors and instead of failing produce Errors.

@ivg

harden the parser also.

@ivg

ivg approved these changes Oct 29, 2018

@ivg ivg merged commit 27378d2 into BinaryAnalysisPlatform:master Oct 30, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment