Fix buffer overflow when formatting trace directory