fuse dirent bug???

Rick Macklem rmacklem at uoguelph.ca
Wed Dec 10 03:41:37 UTC 2014


Hi,

While looking at the fuse code to change it to use a new
"struct dirent", I spotted this line, which doesn't look
correct.

Line 358 of sys/fs/fuse/fuse_internal.c:
        ((char *)cookediov->base)[bytesavail] = '\0';
- I think this is intended to null terminate the name,
  since it comes right after the memcpy() of the file name.
However, bytesavail is the value returned by GENERIC_DIRSIZ(),
which means [bytesavail] after "cookediov->base" would be the
first byte after the "struct dirent" (including the space for
null termination and padding.

If I'm correct, I think this line can be replaced by:
        de->d_name[fudge->namelen] = '\0';
which would be the byte after the name in the structure.

Also, although I think the first argument to the memcpy() call
just above this is correct, it is complex/convoluted.
Wouldn't just writing "memcpy(de->d_name, ..." make it
more readable?

Anyone out there familiar with fuse able to look at/test this?

Thanks, rick


More information about the freebsd-fs mailing list