Thank you for your file system tutorial, it has helped me a lot.
However, I think that the memcpy
in the do_read
function accesses memory which is out of bounds because size
is 4096, but selectedText
is much shorter.
|
memcpy( buffer, selectedText + offset, size ); |
Surprisingly, valgrind does not complain about this, so maybe I am wrong?
Anyway, it is probably a good idea to also set the correct file size in do_getattr
because some programs simply check the file size and then try to read and use that many bytes, ignoring that fread
might have returned a much smaller number of bytes.