Replace use of sprintf with snprintf.