Is there a C function like sprintf in the Linux kernel?
Yes, just include linux/kernel.h
yes. https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/lib/vsprintf.c#n1828
int snprintf(char *buf, size_t size, const char *fmt, ...)
{
va_list args;
int i;
va_start(args, fmt);
i = vsnprintf(buf, size, fmt, args);
va_end(args);
return i;
}
EXPORT_SYMBOL(snprintf);
sprintf()
by itself is prone to buffer overflows. CERT buffer overflows, Apple, etc