Use snprintf where possible instead of sprintf.