Use vnsprintf instead of vsprintf to prevent buffer overflow