diff --git a/utils/shapefile/shapefile_reader.py b/utils/shapefile/shapefile_reader.py index 1519c670b..a57d516f1 100755 --- a/utils/shapefile/shapefile_reader.py +++ b/utils/shapefile/shapefile_reader.py @@ -29,16 +29,24 @@ def test_record(_type, record) : test_polygon(record) def test_pointz(record): + _type, = struct.unpack(">sys.stderr,"BAD SHAPE FILE: expected 36 bytes got",len(record) sys.exit(1) - _type,x,y,z,m = struct.unpack(">sys.stderr,"BAD SHAPE FILE: expected PointZ or NullShape got",_type sys.exit(1) def test_polygon(record): - _type, x0, y0, x1, y0, num_parts, num_points = struct.unpack(">sys.stderr, "BAD SHAPE FILE: expected Polygon or NullShape got", _type sys.exit(1) @@ -85,7 +93,7 @@ if __name__ == "__main__" : record = struct.Struct(">II") calc_total_size = 50 count = 0 - while shx.tell() < shx_file_length * 2 : + while shx.tell() <= shx_file_length * 2 - 4 * 2 : offset,shx_content_length = record.unpack_from(shx.read(8)) shp.seek(offset*2, os.SEEK_SET) record_number,content_length = record_header.unpack_from(shp.read(8))