gdbsupport: remove uses of vsprintf
When building on macOS, I get:
CXX common-utils.o
/Users/smarchi/src/binutils-gdb/gdbsupport/common-utils.cc:106:3: error: 'vsprintf' 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 vsnprintf(3) instead. [-Werror,-Wdeprecated-declarations]
106 | vsprintf (&str[0], fmt, vp);
| ^
/Users/smarchi/src/binutils-gdb/gdbsupport/common-utils.cc:128:3: error: 'vsprintf' 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 vsnprintf(3) instead. [-Werror,-Wdeprecated-declarations]
128 | vsprintf (&str[0], fmt, args);
| ^
/Users/smarchi/src/binutils-gdb/gdbsupport/common-utils.cc:166:3: error: 'vsprintf' 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 vsnprintf(3) instead. [-Werror,-Wdeprecated-declarations]
166 | vsprintf (&str[curr_size], fmt, args);
| ^
We know that those calls should be safe because we computed the size that
fmt+args take just before, and allocated that many bytes. But I also
don't see a real downside in switching those calls to use vsnprintf and
double check that everything went right.
Change the type of the existing "size" variable in "string_vprintf" to
"int", since that's what vsnprintf returns.
Change-Id: I589d9a170fdd15cc31b44b76689c6d8c324e340a
Approved-By: Andrew Burgess <aburgess@redhat.com>
1 file changed