MCPcopy Create free account
hub / github.com/OSGeo/gdal / ReadBoxData

Method ReadBoxData

gcore/gdaljp2box.cpp:209–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207/************************************************************************/
208
209GByte *GDALJP2Box::ReadBoxData()
210
211{
212 GIntBig nDataLength = GetDataLength();
213 if (nDataLength > 100 * 1024 * 1024)
214 {
215 CPLError(CE_Failure, CPLE_AppDefined,
216 "Too big box : " CPL_FRMT_GIB " bytes", nDataLength);
217 return nullptr;
218 }
219
220 if (VSIFSeekL(fpVSIL, static_cast<vsi_l_offset>(nDataOffset), SEEK_SET) !=
221 0)
222 return nullptr;
223
224 char *pszData = static_cast<char *>(
225 VSI_MALLOC_VERBOSE(static_cast<int>(nDataLength) + 1));
226 if (pszData == nullptr)
227 return nullptr;
228
229 if (static_cast<GIntBig>(VSIFReadL(
230 pszData, 1, static_cast<int>(nDataLength), fpVSIL)) != nDataLength)
231 {
232 CPLError(CE_Failure, CPLE_AppDefined, "Cannot read box content");
233 CPLFree(pszData);
234 return nullptr;
235 }
236
237 pszData[nDataLength] = '\0';
238
239 return reinterpret_cast<GByte *>(pszData);
240}
241
242/************************************************************************/
243/* GetDataLength() */

Callers 15

CollectGMLDataMethod · 0.80
ReadBoxMethod · 0.80
DumpGeoTIFFBoxFunction · 0.80
DumpFTYPBoxFunction · 0.80
DumpIHDRBoxFunction · 0.80
DumpBPCCBoxFunction · 0.80
DumpCOLRBoxFunction · 0.80
DumpPCLRBoxFunction · 0.80
DumpCMAPBoxFunction · 0.80
DumpCDEFBoxFunction · 0.80
DumpRESxBoxFunction · 0.80
DumpRREQBoxFunction · 0.80

Calls 3

CPLErrorFunction · 0.85
VSIFReadLFunction · 0.85
VSIFSeekLFunction · 0.50

Tested by

no test coverage detected