Read buffer overflow fix.

Fixes:
* memcpy cannot be used with overlapping memory areas and terminating \0 needs to be copied as well,
* read buffer has to be one byte larger than maximum read count.