sprintf-related integer and memory overflow issues