Skip to content

Commit

Permalink
[Proxy Server] Avoid SEGV when close(), closedir() returns an error.
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 committed Apr 21, 2017
1 parent 6efba1c commit 4dd566c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/XrdPss/XrdPss.cc
Expand Up @@ -608,12 +608,14 @@ int XrdPssDir::Readdir(char *buff, int blen)
*/
int XrdPssDir::Close(long long *retsz)
{
DIR *theDir;

// Close the directory proper if it exists
// Close the directory proper if it exists. POSIX specified that directory
// stream is no longer available after closedir() regardless if return value.
//
if (myDir)
{if (XrdPosixXrootd::Closedir(myDir)) return -errno;
myDir = 0;
if ((theDir = myDir))
{myDir = 0;
if (XrdPosixXrootd::Closedir(theDir)) return -errno;
return XrdOssOK;
}

Expand Down Expand Up @@ -697,12 +699,13 @@ int XrdPssFile::Open(const char *path, int Oflag, mode_t Mode, XrdOucEnv &Env)
Output: Returns XrdOssOK upon success aud -errno upon failure.
*/
int XrdPssFile::Close(long long *retsz)
{
if (fd < 0) return -XRDOSS_E8004;
{ int rc;

if (retsz) *retsz = 0;
if (XrdPosixXrootd::Close(fd)) return -errno;
if (fd < 0) return -XRDOSS_E8004;
rc = XrdPosixXrootd::Close(fd);
fd = -1;
return XrdOssOK;
return (rc == 0 ? XrdOssOK : -errno);
}

/******************************************************************************/
Expand Down

0 comments on commit 4dd566c

Please sign in to comment.