Opened 11 years ago

Last modified 11 years ago

#5203 closed defect

Implicit signed-to-unsigned conversions in rasterfill.cpp — at Initial Version

Reported by: akhliustov Owned by: warmerdam
Priority: normal Milestone: 1.10.1
Component: Algorithms Version: unspecified
Severity: normal Keywords:
Cc:

Description

  1. http://trac.osgeo.org/gdal/browser/trunk/gdal/alg/rasterfill.cpp#L571

if( iY - panLastY[iX] <= dfMaxSearchDist )

panLastY[iX] is unsigned, so iY - panLastY[iX] is unsigned too. If iY < panLastY[iX], their "difference" is a large positive number that can be greater than dfMaxSearchDist. In that case the condition evaluates to false, which is (probably) not expected.

  1. http://trac.osgeo.org/gdal/browser/trunk/gdal/alg/rasterfill.cpp#L333

    double dfDistSq = ((target_x-origin_x) * (target_x-origin_x)) + ((target_y-origin_y) * (target_y-origin_y));

    Here target_y is unsigned, so the whole right-hand expression uses unsigned arithmetics. If target_x < origin_x or target_y < origin_y, it leads to a totally wrong result.

Change History (1)

by akhliustov, 11 years ago

Attachment: rasterfill.unsigned.patch added
Note: See TracTickets for help on using tickets.