Silence warning about unsafe sprintf, use snprintf instead

Apple lets us know that:
  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.

Pick-to: 6.5
Change-Id: I3130b3c7b636466b5e77adc5cb05ad4ce1faee11
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Volker Hilsheimer 2023-03-04 10:06:22 +01:00
parent cacc53e427
commit 386dcbf6b9

View File

@ -70,7 +70,7 @@ namespace QTest {
char *toString(const Ip6 &ip6)
{
char buf[sizeof "1111:2222:3333:4444:5555:6666:7777:8888" + 2];
sprintf(buf, "%x:%x:%x:%x:%x:%x:%x:%x",
snprintf(buf, sizeof(buf), "%x:%x:%x:%x:%x:%x:%x:%x",
ip6.u8[0] << 8 | ip6.u8[1],
ip6.u8[2] << 8 | ip6.u8[3],
ip6.u8[4] << 8 | ip6.u8[5],