Even better emulate POSIX file functions (reduced)

This is reduced version of #5694.
Only obvious fixes.
Reading is requested, buffer at pointer can be modified (in case of bug or bad handling of zero size).
Providing a small real buffer is simple precaution and doesn't affect performance as calls with zero buffer and size are really rare.