mirror of
https://github.com/KLayout/klayout.git
synced 2026-08-29 01:14:35 +02:00
Cap PixelBuffer.from_bytes dimensions at 64k x 64k
Following review feedback, the reader now rejects a header claiming a
width or height beyond 65536, guarding against malformed byte streams
that would otherwise trigger an unreasonable allocation. The writer
stays full 32-bit ('unlimited'), and native little-endian order and the
transparency mask are kept as-is. Adds Ruby and Python tests for the
oversized-header rejection.
Ref: https://github.com/KLayout/klayout/pull/2387#issuecomment-4984941409
This commit is contained in:
Vendored
+4
@@ -78,6 +78,10 @@ class LAYPixelBufferTests(unittest.TestCase):
|
||||
with self.assertRaises(Exception):
|
||||
pya.PixelBuffer.from_bytes(data[:-4])
|
||||
|
||||
# a header beyond the 64k x 64k limit is rejected
|
||||
with self.assertRaises(Exception):
|
||||
pya.PixelBuffer.from_bytes(struct.pack("=II", 65537, 1))
|
||||
|
||||
|
||||
# run unit tests
|
||||
if __name__ == '__main__':
|
||||
|
||||
Vendored
+9
@@ -176,6 +176,15 @@ class LAYPixelBuffer_TestClass < TestBase
|
||||
end
|
||||
assert_equal(error, true)
|
||||
|
||||
# a header beyond the 64k x 64k limit is rejected
|
||||
error = false
|
||||
begin
|
||||
RBA::PixelBuffer.from_bytes([ 65537, 1 ].pack("VV"))
|
||||
rescue
|
||||
error = true
|
||||
end
|
||||
assert_equal(error, true)
|
||||
|
||||
end
|
||||
|
||||
def test_11
|
||||
|
||||
Reference in New Issue
Block a user