Changeset 12384
- Timestamp:
- 10/12/07 16:37:55 (9 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/warmerdam/1.4-esri/gdal/frmts/jpeg/jpgdataset.cpp
r10990 r12384 397 397 /* Read number of entry in directory */ 398 398 /* -------------------------------------------------------------------- */ 399 VSIFSeekL(fp, nOffset+nTIFFHEADER, SEEK_SET);400 401 if(VSIFReadL(&nEntryCount,1,sizeof(GUInt16),fp) != sizeof(GUInt16))399 if( VSIFSeekL(fp, nOffset+nTIFFHEADER, SEEK_SET) != 0 400 || VSIFReadL(&nEntryCount,1,sizeof(GUInt16),fp) != sizeof(GUInt16) ) 401 { 402 402 CPLError( CE_Failure, CPLE_AppDefined, 403 "Error directory count"); 403 "Error reading EXIF Directory count at %d.", 404 nOffset + nTIFFHEADER ); 405 return CE_Failure; 406 } 404 407 405 408 if (bSwabflag) … … 410 413 return CE_None; 411 414 415 // Some files are corrupt, a large entry count is a sign of this. 416 if( nEntryCount > 125 ) 417 { 418 CPLError( CE_Warning, CPLE_AppDefined, 419 "Ignoring EXIF directory with unlikely entry count (%d).", 420 nEntryCount ); 421 return CE_Warning; 422 } 423 412 424 poTIFFDir = (TIFFDirEntry *)CPLMalloc(nEntryCount * sizeof(TIFFDirEntry)); 413 425 414 426 if (poTIFFDir == NULL) 427 { 415 428 CPLError( CE_Failure, CPLE_AppDefined, 416 429 "No space for TIFF directory"); 430 return CE_Failure; 431 } 417 432 418 433 /* -------------------------------------------------------------------- */ … … 421 436 n = VSIFReadL(poTIFFDir, 1,nEntryCount*sizeof(TIFFDirEntry),fp); 422 437 if (n != nEntryCount*sizeof(TIFFDirEntry)) 438 { 423 439 CPLError( CE_Failure, CPLE_AppDefined, 424 440 "Could not read all directories"); 441 return CE_Failure; 442 } 425 443 426 444 /* -------------------------------------------------------------------- */ … … 439 457 /* -------------------------------------------------------------------- */ 440 458 pszName[0] = '\0'; 459 pszTemp[0] = '\0'; 441 460 442 461 for (poExifTags = tagnames; poExifTags->tag; poExifTags++) … … 559 578 /* The data is being read where tdir_offset point to in the file */ 560 579 /* -------------------------------------------------------------------- */ 561 else {562 580 else if (space > 0 && space < MAXSTRINGLENGTH) 581 { 563 582 unsigned char *data = (unsigned char *)CPLMalloc(space); 564 583 … … 601 620 } 602 621 } 622 else 623 { 624 CPLError( CE_Warning, CPLE_AppDefined, 625 "Invalid EXIF header size: %ld, ignoring tag.", space ); 626 } 627 603 628 papszMetadata = CSLSetNameValue(papszMetadata, pszName, pszTemp); 604 629 }
