Ensure FileNode.data is initialized in __init__ and is not used if it… - #20
Ensure FileNode.data is initialized in __init__ and is not used if it…#20cccs-jh wants to merge 2 commits into
Conversation
DissectMalware
commented
Jan 29, 2024
Thank you for the PR. Can you please give me a sample file so I can test it? |
cccs-jh
commented
Jan 30, 2024
Unfortunately I can't share the sample that caused the error because it contains client data. I can share that the FileNode that caused the error had an invalid FileNodeID, and a BaseType of 2. The file actually has several FileNodes with invalid FileNodeIDs so fixing this issue probably wouldn't allow the file to be parsed correctly, but it would allow the constructor to complete. That would let the partially parsed results be inspected. Another option would be to raise an error with a meaningful error message on an invalid id, if returning a best approximation on a parsing failure isn't a project goal. Let me see if I can find anything more useful about the file to share. |
DissectMalware
commented
Jan 30, 2024
The underlying issue could stem from parsing errors in the parent nodes. Without access to the actual file, identifying the precise location of these errors would be challenging. Alternatively, you can enable DEBUG mode and share the output with me; this might give more context. |
cccs-jh
commented
Feb 1, 2024
Here is the DEBUG mode log: The first issue seems to be that GlobalIdTableStartFNDX isn't implemented. Since it has a reserved data byte that isn't being read, the following FileNodes are offset by one byte and become invalid. Fixing that (and GlobalIdTableEntry3FNDX) gives the following debug information: Which is better but the GlobalIdTables still seem like they are followed by junk/uninterpretable data. Which they might be, the file is wrong in a couple ways, notably that it is a .one and not a .onetoc2 file per |
cccs-jh
commented
Feb 1, 2024
I've updated the request with the changes that allow the onetoc2 GlobalIdTable to be parsed without missalignment. |
DissectMalware
commented
Feb 6, 2024
In a few days, I will check the file format reference and merge if I couldn't find an issue. Thanks for all of your efforts on this |
cccs-jh
commented
Feb 7, 2024
You're welcome. Thank you for the interest. |
orangeruan128
commented
Apr 20, 2026
Independent reproduction: applying this patch on top of The two-part shape of the fix matches what's needed in practice:
After this PR is applied (combined with #16 for |
… is None.
Currently if the file_node_type is not handled data is uninitialized and can cause an AttributeError.