Skip to content

Commit

Permalink
xrootdfs: check file descriptor before using it in xrootdfs wcache
Browse files Browse the repository at this point in the history
If file open failed with ENOSYS (it can if the server responded with kXR_Unsupported), then file descriptor is not initialized.
As a result any attempt to write to the file gives a segfault. This check gives a EBADF instead.
  • Loading branch information
fizmat committed May 5, 2017
1 parent e521131 commit 6e43fb8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/XrdFfs/XrdFfsWcache.cc
Expand Up @@ -161,6 +161,11 @@ ssize_t XrdFfsWcache_pwrite(int fd, char *buf, size_t len, off_t offset)
ssize_t rc;
char *bufptr;
fd -= XrdFfsPosix_baseFD;
if (fd < 0)
{
errno = EBADF;
return -1;
}

/* do not use caching under these cases */
if (len > XrdFfsWcacheBufsize/2 || fd >= XrdFfsWcacheNFILES)
Expand Down

0 comments on commit 6e43fb8

Please sign in to comment.