Remove uses of sprintf to fix this warning:
warning: 'sprintf' is deprecated: This function is provided for
compatibility reasons only. Due to security concerns inherent in the
design of sprintf(3), it is highly recommended that you use snprintf(3)
instead. [-Wdeprecated-declarations]
Change-Id: Ifff3746c1cc4e51a8cf4c08ccd845c887d76c6be
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
{
char *new_str;
size_t oldlen = (*s) ? strlen(*s) : 0;
+ size_t addlen = 0;
int ret;
va_list args;
}
/* Allocate space for old string + new string + \0. */
- new_str = zmalloc<char>(oldlen + ret + 1);
+ addlen = ret + 1;
+ new_str = zmalloc<char>(oldlen + addlen);
if (!new_str) {
ret = -ENOMEM;
goto end;
/* Format new string in-place. */
va_start(args, fmt);
- ret = vsprintf(&new_str[oldlen], fmt, args);
+ ret = vsnprintf(&new_str[oldlen], addlen, fmt, args);
va_end(args);
if (ret == -1) {
}
/* Section integer -> section string */
- ret = sprintf(section_string, "%d", section);
+ ret = snprintf(section_string, sizeof(section_string), "%d", section);
LTTNG_ASSERT(ret > 0 && ret < 8);
/*