Make sprintf'ed strings sprintf-safe. Fixes #1665.