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

Ensure FileNode.data is initialized in __init__ and is not used if it… #20

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion pyOneNote/FileNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,19 @@ def __init__(self, file, document):
elif self.file_node_header.file_node_type in ["RevisionManifestEndFND", "ObjectGroupEndFND"]:
# no data part
self.data = None
elif self.file_node_header.file_node_type == "GlobalIdTableStartFNDX":
self.data = GlobalIdTableStartFNDX(file)
elif self.file_node_header.file_node_type == "GlobalIdTableEntry2FNDX":
self.data = GlobalIdTableEntry2FNDX(file)
elif self.file_node_header.file_node_type == "GlobalIdTableEntry3FNDX":
self.data = GlobalIdTableEntry3FNDX(file)
else:
# ensure self.data is initialized
self.data = None
p = 1

current_offset = file.tell()
if self.file_node_header.baseType == 2:
if self.file_node_header.baseType == 2 and self.data is not None:
self.children.append(FileNodeList(file, self.document, self.data.ref))
file.seek(current_offset)

Expand Down Expand Up @@ -324,6 +332,21 @@ def __init__(self, file):
self.guid = uuid.UUID(bytes_le=self.guid)


class GlobalIdTableEntry2FNDX:
def __init__(self, file):
self.iIndexMapFrom, self.iIndexMapTo = struct.unpack('<II', file.read(8))


class GlobalIdTableEntry3FNDX:
def __init__(self, file):
self.iIndexCopyFromStart, self.cEntriesToCopy, self.iIndexCopyToStart = struct.unpack('<III', file.read(12))


class GlobalIdTableStartFNDX:
def __init__(self, file):
self.reserved = file.read(1)


class DataSignatureGroupDefinitionFND:
def __init__(self, file):
self.DataSignatureGroup = ExtendedGUID(file)
Expand Down