OSGeo / libgeotiff

Official repository of the libgeotiff project
189 stars 72 forks source link

GTIFNewWithMethodsEx: Fix allocation of tempData. #96

Closed schwehr closed 1 year ago

schwehr commented 1 year ago

tempData.tk_asciiParams is freed in the failure handler, so tempData must be allocated before the first goto failure;

Found with a GDAL geotiff fuzzer.

Caused by changes to geo_new.c in https://github.com/OSGeo/libgeotiff/commit/e98322fe0e4dabec16d428cd397ed7050f5aad7a

rouault commented 1 year ago

this is a regression related to recent changes related to localizing variables, right? It sucks so much that the compiler accepts to compile such code

schwehr commented 1 year ago

this is a regression related to recent changes related to localizing variables, right? It sucks so much that the compiler accepts to compile such code

Correct. I should have put https://github.com/OSGeo/libgeotiff/commit/e98322fe0e4dabec16d428cd397ed7050f5aad7a in the commit message. I did a git amend to do that. None of the compilers caught this. I totally thought they would. "sucks" is an understatement.