in Solaris openFileToWrite returns an error code that is not checked correctly
------------------------------------------------------------------------------
Key: XERCESC-1356
URL: http://issues.apache.org/jira/browse/XERCESC-1356
Project: Xerces-C++
Type: Bug
Components: Utilities
Versions: 2.6.0
Environment: solaris 2.8
Reporter: Luc Maisonobe
Priority: Minor
In Solaris, the FileHandle typedef is an int representing the file descriptor
returned from an "open" system call in the two
XMLPlatformUtils::openFileToWrite methods.
The constructors of LocalFileFormatTarget check the error using the following
statement :
if (!fSource)
ThrowXMLwithMemMgr1(...)
This is correct only for FileHandle types where 0 is an unusable handle (Linux,
for example, where the FileHandle typedef is void* and truly contains a File*
returned by a "fopen" call). For Solaris, error values are represented by -1
and the check performed in LocalFileFormatTarget constructors does not detect
the error (it appears later when attempting to write, with a
File_CouldNotWriteToFile XMLPlatformUtilsException).
Since the LocalFileFormatTarget constructor also use 0 as the default value
when initializing its attributes, since 0 as a file descriptor represents the
standard input and since XMLPlatformUtils::openFileToWrite is called only by
the LocalFileFormatTarget and BinFileOutputStream constructors, I suggest to
keep it as a forbidden FileHandle even for platforms using file descriptors,
and to change the two Solaris implementations of openFileToWrite like this :
replace
return (FileHandle)open(fileName ,
O_WRONLY | O_CREAT | O_TRUNC | O_LARGEFILE,
0666);
by
int fd = open(fileName ,
O_WRONLY | O_CREAT | O_TRUNC | O_LARGEFILE,
0666);
return (FileHandle) ((fd < 0) ? 0 : fd);
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]