Fill the error message buffer from back to front

This way the most important information is preserved if truncation happens.
Add function for inserting strerror (errno) to error