sprintf was not null terminating string