Fix buffer overflow when formatting trace directory

Fixes #47.