Pass the length along when outputting from printf

If there's no length, the result is treated as a null-terminated string
which means that null characters incorrectly stop the output.