Ticket #2218 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

[PATCH - shapelib] Fix crashes on corrupted geometries

Reported by: rouault Owned by: rouault
Priority: low Milestone: 1.6.0
Component: OGR_SF Version: unspecified
Severity: normal Keywords: shape
Cc:

Description

The attached patch adds checks to SHPReadObject so that hostile/corrupted geometries in a shape entity don't cause shapelib to read memory outside of the declared entity size and pabyRec buffer.

I've attached too a zip file containing a few volontary corrupted shapefiles to demonstrate the crashes (or Valgrind errors) and the fix.

Attachments

buggyshape.zip Download (2.4 KB) - added by rouault 4 years ago.
shapelib_fix_crash_on_buggy_geometries.patch Download (11.4 KB) - added by rouault 4 years ago.

Change History

Changed 4 years ago by rouault

Patch updated that also checks for two big number of points or parts that would cause arithmetic computation overflow, and another test that checks that the panPartStart array is correct (checks of the indices wrt the number of points and that they appear in increasing orders).

ZIP also updated to add another shape that demonstrates the checks on panPartStart.

Changed 4 years ago by rouault

Changed 4 years ago by rouault

Changed 4 years ago by warmerdam

  • priority changed from normal to high
  • status changed from new to assigned
  • milestone set to 1.5.1

I'll try to incorporate this for 1.5.1.

Changed 4 years ago by warmerdam

  • priority changed from high to low
  • milestone changed from 1.5.1 to 1.6.0

Patch applied in Shapelib.

Patch downstreamed and applied in trunk (r14000) and 1.5 branch (r14001).

I would appreciate it if some sort of test case(s) could be added to the gdalautotest. Leaving open for that (in trunk only would be fine).

Changed 4 years ago by rouault

  • owner changed from warmerdam to rouault
  • status changed from assigned to new

I will take care of adding test cases in gdalautotest. There will be based on the shapefiles in the buggyshape.zip archive

Changed 4 years ago by rouault

  • status changed from new to closed
  • resolution set to fixed

ogr_shape_21 test added in r14015

Note: See TracTickets for help on using tickets.