From Paul Martz, "Attached are some minor plugin fixes. PNM, RGB, and JPEG would all crash if attempting to read an empty file, and FLT would go into an infinite loop. All are fixed with this change.
I also fixed some return values for a couple of these, changing FILE_NOT_HANDLED to ERROR_IN_READING_FILE where appropriate."
This commit is contained in:
parent
01f58ffbb2
commit
61e3285ffc
@ -299,6 +299,9 @@ class FLTReaderWriter : public ReaderWriter
|
||||
opcode_type opcode = (opcode_type)dataStream.readUInt16();
|
||||
size_type size = (size_type)dataStream.readUInt16();
|
||||
|
||||
if (size==0)
|
||||
return ReadResult::ERROR_IN_READING_FILE;
|
||||
|
||||
// variable length record complete?
|
||||
if (!continuationBuffer.empty() && opcode!=CONTINUATION_OP)
|
||||
{
|
||||
|
@ -614,6 +614,9 @@ class ReaderWriterJPEG : public osgDB::ReaderWriter
|
||||
{
|
||||
WriteResult::WriteStatus write_JPEG_file (std::ostream &fout,int image_width,int image_height,JSAMPLE* image_buffer,int quality = 100) const
|
||||
{
|
||||
if ( (image_width == 0) || (image_height == 0) )
|
||||
return WriteResult::ERROR_IN_WRITING_FILE;
|
||||
|
||||
/* This struct contains the JPEG compression parameters and pointers to
|
||||
* working space (which is allocated as needed by the JPEG library).
|
||||
* It is possible to have several such structures, representing multiple
|
||||
|
@ -279,7 +279,8 @@ class ReaderWriterPNM : public osgDB::ReaderWriter
|
||||
int row;
|
||||
for (row = 1; row <= 3; row++)
|
||||
{
|
||||
fgets(line, 300, fp);
|
||||
if ( fgets(line, 300, fp) == NULL)
|
||||
break;
|
||||
|
||||
char *cp = line;
|
||||
while (*cp && isspace(*cp))
|
||||
@ -326,7 +327,7 @@ class ReaderWriterPNM : public osgDB::ReaderWriter
|
||||
ppmtype < 1 || ppmtype > 6)
|
||||
{
|
||||
fclose(fp);
|
||||
return ReadResult::FILE_NOT_HANDLED;
|
||||
return ReadResult::ERROR_IN_READING_FILE;
|
||||
}
|
||||
|
||||
int pixelFormat = 0;
|
||||
|
@ -168,6 +168,8 @@ static rawImageRec *RawImageOpen(std::istream& fin)
|
||||
}
|
||||
|
||||
fin.read((char*)raw,12);
|
||||
if (!fin.good())
|
||||
return NULL;
|
||||
|
||||
if (raw->swapFlag)
|
||||
{
|
||||
@ -459,7 +461,7 @@ class ReaderWriterRGB : public osgDB::ReaderWriter
|
||||
|
||||
if( (raw = RawImageOpen(fin)) == NULL )
|
||||
{
|
||||
return ReadResult::FILE_NOT_HANDLED;
|
||||
return ReadResult::ERROR_IN_READING_FILE;
|
||||
}
|
||||
|
||||
int s = raw->sizeX;
|
||||
|
Loading…
Reference in New Issue
Block a user