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

createOperations(): Fix possible null dereference on invalid WKT input #3945

Merged
merged 2 commits into from
Nov 4, 2023

Conversation

drons
Copy link
Contributor

@drons drons commented Nov 4, 2023

Null pointer dereference can be reproduced with 1.prj.txt

Stack trace (before fix):

gdb --args projinfo @1.prj
Program received signal SIGSEGV, Segmentation fault.
std::__uniq_ptr_impl<osgeo::proj::common::ObjectUsage::Private, std::default_delete<osgeo::proj::common::ObjectUsage::Private> >::_M_ptr (this=0x28) at /usr/include/c++/10/bits/unique_ptr.h:173
173	      pointer    _M_ptr() const { return std::get<0>(_M_t); }
(gdb) bt
#0  std::__uniq_ptr_impl<osgeo::proj::common::ObjectUsage::Private, std::default_delete<osgeo::proj::common::ObjectUsage::Private> >::_M_ptr (this=0x28) at /usr/include/c++/10/bits/unique_ptr.h:173
#1  0x00007ffff7bcd1a2 in std::unique_ptr<osgeo::proj::common::ObjectUsage::Private, std::default_delete<osgeo::proj::common::ObjectUsage::Private> >::get (this=0x28) at /usr/include/c++/10/bits/unique_ptr.h:422
#2  0x00007ffff7bce8d6 in std::unique_ptr<osgeo::proj::common::ObjectUsage::Private, std::default_delete<osgeo::proj::common::ObjectUsage::Private> >::operator-> (this=0x28) at /usr/include/c++/10/bits/unique_ptr.h:416
#3  0x00007ffff7bcbe70 in osgeo::proj::common::ObjectUsage::domains (this=0x0)
    at /tmp/proj.4/src/iso19111/common.cpp:1188
#4  0x00007ffff7dd9fa6 in osgeo::proj::operation::getExtent (crs=...)
    at /tmp/proj.4/src/iso19111/operation/oputils.cpp:480
#5  0x00007ffff7dad224 in osgeo::proj::crs::CRS::getResolvedCRS (crs=..., authFactory=
    std::shared_ptr<osgeo::proj::io::AuthorityFactory> (use count 2, weak count 1) = {...}, 
    extentOut=std::shared_ptr<osgeo::proj::metadata::Extent> (empty) = {...})
    at /tmp/proj.4/src/iso19111/operation/coordinateoperationfactory.cpp:7177
#6  0x00007ffff7dac3bf in osgeo::proj::operation::CoordinateOperationFactory::createOperations (this=0x555555685a90, 
    sourceCRS=..., targetCRS=..., context=...) at /tmp/proj.4/src/iso19111/operation/coordinateoperationfactory.cpp:6992
#7  0x00007ffff7bda4cf in osgeo::proj::crs::CRS::createBoundCRSToWGS84IfPossible (this=0x55555568f360, 
    dbContext=std::shared_ptr<osgeo::proj::io::DatabaseContext> (use count 4, weak count 1) = {...}, 
    allowIntermediateCRSUse=osgeo::proj::operation::CoordinateOperationContext::IntermediateCRSUse::IF_NO_DIRECT_TRANSFORMATION) at /tmp/proj.4/src/iso19111/crs.cpp:673
#8  0x0000555555577027 in outputObject (
    dbContext=std::shared_ptr<osgeo::proj::io::DatabaseContext> (use count 4, weak count 1) = {...}, obj=..., 
    allowUseIntermediateCRS=osgeo::proj::operation::CoordinateOperationContext::IntermediateCRSUse::IF_NO_DIRECT_TRANSFORMATION, outputOpt=...) at /tmp/proj.4/src/apps/projinfo.cpp:490
#9  0x000055555557e2b1 in main (argc=2, argv=0x7fffffffdfa8) at /tmp/proj.4/src/apps/projinfo.cpp:1624

@rouault rouault merged commit e9c0e8c into OSGeo:master Nov 4, 2023
23 checks passed
@drons drons deleted the fix_getExtent_null_dereference branch November 5, 2023 16:50
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 this pull request may close these issues.

2 participants