-
Notifications
You must be signed in to change notification settings - Fork 565
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
viv: insn: string: handle viv bug around substrings #1273
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ffef4a2
viv: insn: string: handle viv bug around substrings
williballenthin ca9c940
use minimum string length 4
mr-tz 3e83a66
update changelog
mr-tz dcf5a0f
update overlapping string test
mr-tz 25a1575
fixup vivisect elf analysis missing function
mr-tz 4c1828d
Merge branch 'master' into fix/issue-1271
mr-tz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -281,7 +281,12 @@ def read_string(vw, offset: int) -> str: | |
pass | ||
else: | ||
if alen > 0: | ||
return read_memory(vw, offset, alen).decode("utf-8") | ||
buf = read_memory(vw, offset, alen) | ||
if b"\x00" in buf: | ||
# account for bug #1271. | ||
# remove when vivisect is fixed. | ||
buf = buf.partition(b"\x00")[0] | ||
return buf.decode("utf-8") | ||
|
||
try: | ||
ulen = vw.detectUnicode(offset) | ||
|
@@ -300,7 +305,9 @@ def read_string(vw, offset: int) -> str: | |
# vivisect seems to mis-detect the end unicode strings | ||
# off by two, too short | ||
ulen += 2 | ||
return read_memory(vw, offset, ulen).decode("utf-16") | ||
# partition to account for bug #1271. | ||
# remove when vivisect is fixed. | ||
return read_memory(vw, offset, ulen).decode("utf-16").partition("\x00")[0] | ||
Comment on lines
+308
to
+310
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we're not really able to guess at the correct string length. this has an edge case where we have |
||
|
||
raise ValueError("not a string", offset) | ||
|
||
|
@@ -665,11 +672,12 @@ def extract_op_string_features( | |
|
||
for v in derefs(f.vw, v): | ||
try: | ||
s = read_string(f.vw, v) | ||
s = read_string(f.vw, v).rstrip("\x00") | ||
except ValueError: | ||
continue | ||
else: | ||
yield String(s.rstrip("\x00")), ih.address | ||
if len(s) > 4: | ||
yield String(s), ih.address | ||
|
||
|
||
def extract_operand_features(f: FunctionHandle, bb, insn: InsnHandle) -> Iterator[Tuple[Feature, Address]]: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should really never be the case, but viv is broken