Merge pull request #593 from trapexit/outbuf

ioctl: don't set outbufsz when not needed
This commit is contained in:
trapexit 2019-03-20 10:30:56 -04:00 committed by GitHub
commit 8bd09628ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 16 deletions

View File

@ -888,7 +888,7 @@ struct fuse_lowlevel_ops {
*/ */
void (*ioctl) (fuse_req_t req, fuse_ino_t ino, int cmd, void *arg, void (*ioctl) (fuse_req_t req, fuse_ino_t ino, int cmd, void *arg,
struct fuse_file_info *fi, unsigned flags, struct fuse_file_info *fi, unsigned flags,
const void *in_buf, size_t in_bufsz, size_t out_bufsz); const void *in_buf, uint32_t in_bufsz, uint32_t out_bufsz);
/** /**
* Poll for IO readiness * Poll for IO readiness
@ -1286,7 +1286,7 @@ int fuse_reply_ioctl_retry(fuse_req_t req,
* @param buf buffer containing output data * @param buf buffer containing output data
* @param size length of output data * @param size length of output data
*/ */
int fuse_reply_ioctl(fuse_req_t req, int result, const void *buf, size_t size); int fuse_reply_ioctl(fuse_req_t req, int result, const void *buf, uint32_t size);
/** /**
* Reply to finish ioctl with iov buffer * Reply to finish ioctl with iov buffer

View File

@ -3896,8 +3896,8 @@ static void fuse_lib_bmap(fuse_req_t req, fuse_ino_t ino, size_t blocksize,
static void fuse_lib_ioctl(fuse_req_t req, fuse_ino_t ino, int cmd, void *arg, static void fuse_lib_ioctl(fuse_req_t req, fuse_ino_t ino, int cmd, void *arg,
struct fuse_file_info *llfi, unsigned int flags, struct fuse_file_info *llfi, unsigned int flags,
const void *in_buf, size_t in_bufsz, const void *in_buf, uint32_t in_bufsz,
size_t out_bufsz_) uint32_t out_bufsz_)
{ {
struct fuse *f = req_fuse_prepare(req); struct fuse *f = req_fuse_prepare(req);
struct fuse_intr_data d; struct fuse_intr_data d;

View File

@ -916,23 +916,28 @@ enomem:
goto out; goto out;
} }
int fuse_reply_ioctl(fuse_req_t req, int result, const void *buf, size_t size) int fuse_reply_ioctl(fuse_req_t req, int result, const void *buf, uint32_t size)
{ {
struct fuse_ioctl_out arg; int count;
struct iovec iov[3]; struct iovec iov[3];
size_t count = 1; struct fuse_ioctl_out arg;
memset(&arg, 0, sizeof(arg)); arg.result = result;
arg.result = result; arg.flags = 0;
arg.in_iovs = 0;
arg.out_iovs = 0;
count = 1;
iov[count].iov_base = &arg; iov[count].iov_base = &arg;
iov[count].iov_len = sizeof(arg); iov[count].iov_len = sizeof(arg);
count++; count++;
if (size) { if(size)
iov[count].iov_base = (char *) buf; {
iov[count].iov_len = size; iov[count].iov_base = (char*)buf;
count++; iov[count].iov_len = size;
} count++;
}
return send_reply_iov(req, 0, iov, count); return send_reply_iov(req, 0, iov, count);
} }

View File

@ -90,7 +90,8 @@ namespace l
case FS_IOC_SETVERSION: case FS_IOC_SETVERSION:
if(endian::is_big() && (sizeof(long) != sizeof(int))) if(endian::is_big() && (sizeof(long) != sizeof(int)))
return -ENOTTY; return -ENOTTY;
*out_bufsz_ = 4; if((data_ != NULL) && (*out_bufsz_ > 4))
*out_bufsz_ = 4;
break; break;
} }