Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.7.0
-
None
-
Solaris 10
Description
XMLPlatformUtils::openFile() in SolarisPlatformUtils.cpp:227 directly returns the result of the open(2) system call.
This can return -1 on error, such as "File not found". However other parts of Xerces take this return could without further validation. Also, when an error occurs, valuable information is available for a short time in errno, this information (i.e. the reason why -1 was return) is not captured for use in error messages.
An example of when the return is stored is in
BinFileInputStream::BinFileInputStream(const XMLCh* const fileName, MemoryManager* const manager)
Here fSource can end up with a value of -1, which in turn means that the destructor for BinFileInputStream will fail.
BinFileInputStream::~BinFileInputStream()
{
if (fSource)
XMLPlatformUtils::closeFile(fSource, fMemoryManager);
}
It detects that fSource is non-zero and tries to close the file, but -1 is not a valid file descriptor.
Hence we end up with the inaccurate error message "Could not close the file".
Error checking surrounding XMLPlatformUtils::openFile() should be improved.
Thank you,
Paul