Restrict marshal.loads when magic is the same. This is more stringent than using the Python major/minor version

This commit is contained in:
rocky
2015-12-17 22:34:13 -05:00
parent 97f48f1322
commit 78847fe454

View File

@@ -31,7 +31,7 @@ from __future__ import print_function
Probably a complete rewrite would be sensefull. hG/2000-12-27 Probably a complete rewrite would be sensefull. hG/2000-12-27
''' '''
import os, marshal, sys, types import imp, os, marshal, sys, types
# set before importing scanner # set before importing scanner
PYTHON3 = (sys.version_info >= (3, 0)) PYTHON3 = (sys.version_info >= (3, 0))
@@ -103,8 +103,9 @@ def load_module(filename):
# print version # print version
fp.read(4) # timestamp fp.read(4) # timestamp
magic_int = magics.magic2int(magic) magic_int = magics.magic2int(magic)
my_magic_int = magics.magic2int(imp.get_magic())
if version == PYTHON_VERSION: if my_magic_int == magic_int:
# Note: a higher magic number necessarily mean a later # Note: a higher magic number necessarily mean a later
# release. At Python 3.0 the magic number decreased # release. At Python 3.0 the magic number decreased
# significantly. Hence the range below. Also note # significantly. Hence the range below. Also note