sprintf -> snprintf and strcat -> strlcat