Skip to content

Commit e84cfc2

Browse files
Add files via upload
1 parent e885352 commit e84cfc2

1 file changed

Lines changed: 15 additions & 18 deletions

File tree

pyarchivefile.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9707,6 +9707,7 @@ def ArchiveFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_
97079707
return False
97089708
if(formdel != formatspecs['format_delimiter']):
97099709
return False
9710+
headeroffset = fp.tell()
97109711
if(__use_new_style__):
97119712
inheader = ReadFileHeaderDataBySize(fp, formatspecs['format_delimiter'])
97129713
else:
@@ -9725,24 +9726,9 @@ def ArchiveFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_
97259726
fjsonsize = int(inheader[10], 16)
97269727
fjsonchecksumtype = inheader[11]
97279728
fjsonchecksum = inheader[12]
9729+
headerjsonoffset = fp.tell()
97289730
fprejsoncontent = fp.read(fjsonsize)
97299731
jsonfcs = GetFileChecksum(fprejsoncontent, fjsonchecksumtype, True, formatspecs, saltkey)
9730-
if(fjsonsize > 0):
9731-
if(CheckChecksums(jsonfcs, fjsonchecksum)):
9732-
if(verbose):
9733-
VerbosePrintOut("File JSON Data Checksum Passed at offset " + str(outfjstart))
9734-
VerbosePrintOut("'" + outfjsonchecksum + "' == " + "'" + injsonfcs + "'")
9735-
else:
9736-
valid_archive = False
9737-
invalid_archive = True
9738-
if(verbose):
9739-
VerbosePrintOut("File JSON Data Checksum Error at offset " + str(outfjstart))
9740-
VerbosePrintOut("'" + outfjsonchecksum + "' != " + "'" + injsonfcs + "'")
9741-
if(not CheckChecksums(fjsonchecksum, jsonfcs) and not skipchecksum):
9742-
VerbosePrintOut("File JSON Data Checksum Error with file " +
9743-
fname + " at offset " + str(fheaderstart))
9744-
VerbosePrintOut("'" + fjsonchecksum + "' != " + "'" + jsonfcs + "'")
9745-
return False
97469732
# Next seek directive
97479733
if(re.findall(r"^\+([0-9]+)", outfseeknextfile)):
97489734
fseeknextasnum = int(outfseeknextfile.replace("+", ""))
@@ -9779,15 +9765,26 @@ def ArchiveFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_
97799765
VerbosePrintOut("Number of Records " + str(fnumfiles))
97809766
if(headercheck):
97819767
if(verbose):
9782-
VerbosePrintOut("File Header Checksum Passed at offset " + str(0))
9768+
VerbosePrintOut("File Header Checksum Passed at offset " + str(headeroffset))
97839769
VerbosePrintOut("'" + fprechecksum + "' == " + "'" + newfcs + "'")
97849770
else:
97859771
# always flip flags, even when not verbose
97869772
valid_archive = False
97879773
invalid_archive = True
97889774
if(verbose):
9789-
VerbosePrintOut("File Header Checksum Failed at offset " + str(0))
9775+
VerbosePrintOut("File Header Checksum Failed at offset " + str(headeroffset))
97909776
VerbosePrintOut("'" + fprechecksum + "' != " + "'" + newfcs + "'")
9777+
if(fjsonsize > 0):
9778+
if(CheckChecksums(jsonfcs, fjsonchecksum)):
9779+
if(verbose):
9780+
VerbosePrintOut("File JSON Data Checksum Passed at offset " + str(headerjsonoffset))
9781+
VerbosePrintOut("'" + outfjsonchecksum + "' == " + "'" + injsonfcs + "'")
9782+
else:
9783+
valid_archive = False
9784+
invalid_archive = True
9785+
if(verbose):
9786+
VerbosePrintOut("File JSON Data Checksum Error at offset " + str(headerjsonoffset))
9787+
VerbosePrintOut("'" + outfjsonchecksum + "' != " + "'" + injsonfcs + "'")
97919788
if(verbose):
97929789
VerbosePrintOut("")
97939790
# Iterate either until EOF (seektoend) or fixed count

0 commit comments

Comments
 (0)