Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix #4803 -- don't escape DESDATA for sizes >10mb

git-svn-id: https://svn.osgeo.org/gdal/trunk@24911 f0d54148-0727-0410-94bb-9a71ac55c965
  • Loading branch information...
commit 84f2bf1677395cc6d93016256ba45660530790ed 1 parent c1ec77a
@hobu hobu authored
Showing with 44 additions and 23 deletions.
  1. +44 −23 gdal/frmts/nitf/nitfdes.c
View
67 gdal/frmts/nitf/nitfdes.c
@@ -277,32 +277,53 @@ NITFDES *NITFDESAccess( NITFFile *psFile, int iSegment )
}
else
{
- char* pachData = (char*)VSIMalloc((size_t)psSegInfo->nSegmentSize);
- if (pachData == NULL )
- {
- CPLDebug("NITF", "Cannot allocate " CPL_FRMT_GUIB " bytes DES data",
- psSegInfo->nSegmentSize);
- }
- else if( VSIFSeekL( psFile->fp, psSegInfo->nSegmentStart,
- SEEK_SET ) != 0
- || VSIFReadL( pachData, 1, (size_t)psSegInfo->nSegmentSize,
- psFile->fp ) != psSegInfo->nSegmentSize )
+
+#define TEN_MEGABYTES 10485760
+
+ if ((int)psSegInfo->nSegmentSize > TEN_MEGABYTES)
{
- CPLDebug("NITF",
- "Failed to read " CPL_FRMT_GUIB" bytes DES data from " CPL_FRMT_GUIB ".",
- psSegInfo->nSegmentSize,
- psSegInfo->nSegmentStart );
+ char* pszOffset = CPLSPrintf(CPL_FRMT_GUIB, psFile->pasSegmentInfo[iSegment].nSegmentStart);
+ char* pszSize = CPLSPrintf(CPL_FRMT_GUIB, psFile->pasSegmentInfo[iSegment].nSegmentSize);
+
+ psDES->papszMetadata = CSLSetNameValue( psDES->papszMetadata,
+ "NITF_DESDATA_OFFSET",
+ pszOffset );
+ psDES->papszMetadata = CSLSetNameValue( psDES->papszMetadata,
+ "NITF_DESDATA_LENGTH",
+ pszSize);
+
}
else
{
- char* pszEscapedDESDATA =
- CPLEscapeString( pachData,
- (int)psSegInfo->nSegmentSize,
- CPLES_BackslashQuotable );
- psDES->papszMetadata = CSLSetNameValue( psDES->papszMetadata,
- "NITF_DESDATA",
- pszEscapedDESDATA );
- CPLFree(pszEscapedDESDATA);
+ char* pachData = (char*)VSIMalloc((size_t)psSegInfo->nSegmentSize);
+ if (pachData == NULL )
+ {
+ CPLDebug("NITF", "Cannot allocate " CPL_FRMT_GUIB " bytes DES data",
+ psSegInfo->nSegmentSize);
+ }
+ else if( VSIFSeekL( psFile->fp, psSegInfo->nSegmentStart,
+ SEEK_SET ) != 0
+ || VSIFReadL( pachData, 1, (size_t)psSegInfo->nSegmentSize,
+ psFile->fp ) != psSegInfo->nSegmentSize )
+ {
+ CPLDebug("NITF",
+ "Failed to read " CPL_FRMT_GUIB" bytes DES data from " CPL_FRMT_GUIB ".",
+ psSegInfo->nSegmentSize,
+ psSegInfo->nSegmentStart );
+ }
+ else
+ {
+ char* pszEscapedDESDATA =
+ CPLEscapeString( pachData,
+ (int)psSegInfo->nSegmentSize,
+ CPLES_BackslashQuotable );
+ psDES->papszMetadata = CSLSetNameValue( psDES->papszMetadata,
+ "NITF_DESDATA",
+ pszEscapedDESDATA );
+ CPLFree(pszEscapedDESDATA);
+
+ }
+ CPLFree(pachData);
}
#ifdef notdef
@@ -339,7 +360,7 @@ NITFDES *NITFDESAccess( NITFFile *psFile, int iSegment )
}
#endif
- CPLFree(pachData);
+
}
return psDES;
Please sign in to comment.
Something went wrong with that request. Please try again.