You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Alberto Massari (JIRA)" <xe...@xml.apache.org> on 2005/04/28 10:37:23 UTC
[jira] Resolved: (XERCESC-1356) in Solaris openFileToWrite returns an error code that is not checked correctly
[ http://issues.apache.org/jira/browse/XERCESC-1356?page=all ]
Alberto Massari resolved XERCESC-1356:
--------------------------------------
Resolution: Fixed
David committed a patch for this problem yesterday. Can you please verify it fixes your problem?
Thanks,
Alberto
> 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
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org