laszip.net icon indicating copy to clipboard operation
laszip.net copied to clipboard

Seek of uncompressed files incorrectly calculates offset when target is a very large number

Open hellbender3069 opened this issue 3 years ago • 0 comments

In a current project I am working with LARGE LAS files (multi gigabyte files). I had a problem when my source was a LAS file and i needed to seek to points at the end of the files. All the points read had wrong values in them.

The error is in LASreadPoint.cs at line 256. It reads : instream.Seek(point_start + point_size * target, SeekOrigin.Begin);

due to the fact that point_size is of type uint the compiler incorrectly converts the whole calculation to a uint, but it should have converted it to a long. So I needed to change the line to read

instream.Seek(point_start + (long)point_size * target, SeekOrigin.Begin);

which fixed the problem and now it reads beyond the size limit of uint.

I should have made a branch and pull request but forgot to do so, so i am hoping shintadono can include this in his code.

hellbender3069 avatar Nov 04 '20 18:11 hellbender3069