Skip to content

Commit 992d064

Browse files
authored
Merge pull request #39 from Oskar65536/patch-1
Fix LNK Parsing Error in Specific Cases in string_data.py
2 parents ba62c39 + 506daf1 commit 992d064

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

LnkParse3/string_data.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ def __init__(self, lnk_file, indata=None, cp=None):
2525
start = 0
2626
try:
2727
if self._lnk_file.has_name():
28-
text, length = self.read(self._raw[start:])
28+
text, length = self.read(self._raw[start:], limit_length=True)
2929
self._data["description"] = text
3030
start += length
3131

3232
if self._lnk_file.has_relative_path():
33-
text, length = self.read(self._raw[start:])
33+
text, length = self.read(self._raw[start:], limit_length=True)
3434
self._data["relative_path"] = text
3535
start += length
3636

3737
if self._lnk_file.has_working_dir():
38-
text, length = self.read(self._raw[start:])
38+
text, length = self.read(self._raw[start:], limit_length=True)
3939
self._data["working_directory"] = text
4040
start += length
4141

@@ -71,10 +71,10 @@ def command_line_arguments(self):
7171
def icon_location(self):
7272
return self._data.get("icon_location")
7373

74-
def read(self, binary):
74+
def read(self, binary, limit_length=False):
7575
offset = 2
7676
char_count = unpack("<H", binary[0:offset])[0]
77-
length = char_count
77+
length = 260 if limit_length and char_count > 260 else char_count
7878

7979
if self._lnk_file.is_unicode():
8080
self._read = self.text_processor.read_unicode_string

0 commit comments

Comments
 (0)