Skip to content

Commit 184f77d

Browse files
committed
HDF4-EOS: fix heap-buffer-overflow
Fixes #14363
1 parent dd0742a commit 184f77d

4 files changed

Lines changed: 27 additions & 1 deletion

File tree

9.32 KB
Binary file not shown.

autotest/gcore/hdf4_read.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,3 +607,15 @@ def test_hdf4_gh_14356():
607607
pytest.skip()
608608

609609
gdal.Open("data/hdf4/issue_14356.he4")
610+
611+
612+
###############################################################################
613+
# Test bugfix for https://github.com/OSGeo/gdal/issues/14363
614+
615+
616+
def test_hdf4_gh_14363():
617+
618+
if gdaltest.hdf4_drv is None:
619+
pytest.skip()
620+
621+
gdal.Open("data/hdf4/issue_14363.he4")

autotest/gcore/hdf4multidim.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,3 +541,14 @@ def test_hdf4_multidim_gh_14356():
541541
ds = gdal.OpenEx("data/hdf4/issue_14356.he4", gdal.OF_MULTIDIM_RASTER)
542542

543543
gdal.MultiDimInfo(ds)
544+
545+
546+
###############################################################################
547+
# Test bugfix for https://github.com/OSGeo/gdal/issues/14363
548+
549+
550+
def test_hdf4_multidim_gh_14363():
551+
552+
ds = gdal.OpenEx("data/hdf4/issue_14363.he4", gdal.OF_MULTIDIM_RASTER)
553+
554+
gdal.MultiDimInfo(ds)

frmts/hdf4/hdf-eos/GDapi.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3147,7 +3147,10 @@ GDnentries(int32 gridID, int32 entrycode, int32 * strbufsize)
31473147
* Get all string values Don't count quotes
31483148
*/
31493149
EHgetmetavalue(metaptrs, &valName[i][0], utlstr);
3150-
*strbufsize += (int32)strlen(utlstr) - 2;
3150+
if( utlstr[0] == '"' && utlstr[strlen(utlstr)-1] == '"' )
3151+
*strbufsize += (int32)strlen(utlstr) - 2;
3152+
else
3153+
*strbufsize += (int32)strlen(utlstr);
31513154
}
31523155
/* Increment number of entries */
31533156
nEntries++;

0 commit comments

Comments
 (0)