Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CVE-2018-20539: Segmentation fault triggered by illegal address access at liblas::SpatialReference::GetGTIF()(src/spatialreference.cpp:515) #159

Closed
carnil opened this issue Jan 1, 2019 · 2 comments · Fixed by #183

Comments

@carnil
Copy link

carnil commented Jan 1, 2019

The following issue was reported downstream in the Red Hat Bugzilla:

https://bugzilla.redhat.com/show_bug.cgi?id=1652609

(A CVE was apparently assigned and got CVE-2018-20539)

@manisandro
Copy link
Contributor

Proposed patch:

diff -rupN --no-dereference libLAS-d76a061f33a69a36ab116cd939c5d444b301efd8/src/spatialreference.cpp libLAS-d76a061f33a69a36ab116cd939c5d444b301efd8-new/src/spatialreference.cpp
--- libLAS-d76a061f33a69a36ab116cd939c5d444b301efd8/src/spatialreference.cpp	2020-04-05 18:40:29.000000000 +0200
+++ libLAS-d76a061f33a69a36ab116cd939c5d444b301efd8-new/src/spatialreference.cpp	2020-04-14 20:10:51.189663648 +0200
@@ -510,12 +510,15 @@ const GTIF* SpatialReference::GetGTIF()
#pragma pack(pop)

            ShortKeyHeader *header = (ShortKeyHeader *)data.data();
-            // Calculate the number of shorts in the VLR data.
-            // The '+ 1' accounts for the header itself.
-            int count = (header->numKeys + 1) * 4;
-            short *data_s = reinterpret_cast<short *>( &(data[0]));
+            if (header)
+            {
+                // Calculate the number of shorts in the VLR data.
+                // The '+ 1' accounts for the header itself.
+                int count = (header->numKeys + 1) * 4;
+                short *data_s = reinterpret_cast<short *>( &(data[0]));

-            ST_SetKey(m_tiff, record.GetRecordId(), count, STT_SHORT, data_s);
+                ST_SetKey(m_tiff, record.GetRecordId(), count, STT_SHORT, data_s);
+            }
        }

        if (uid == record.GetUserId(true).c_str() &&

@mloskot
Copy link
Member

mloskot commented Apr 14, 2020

@manisandro Please, submit PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants