reject incomplete model buffers (#38852)

This commit is contained in:
Daniel Koepping
2026-09-10 18:17:40 -07:00
committed by GitHub
parent 2a70b40cdc
commit f87e170bee
+2 -1
View File
@@ -41,7 +41,8 @@ def load_oob(f):
def buffers():
while (h := f.read(8)):
pb = pickle.PickleBuffer(bytearray(struct.unpack('<q', h)[0]))
f.readinto(pb)
if f.readinto(pb) != pb.raw().nbytes:
raise EOFError("incomplete model buffer")
yield pb
return pickle.load(io.BytesIO(opcodes), buffers=buffers())