sm6225-common: gps: data-items: Fix snprintf usage

Fixes:
gps/core/data-items/DataItemConcreteTypes.cpp:465:9: error: 'snprintf'
will always be truncated; specified size is 10, but format string
expands to at least 20 [-Werror,-Wfortify-source]
  465 |         snprintf(t, sizeof(t),
        "[%02x:%02x:%02x:%02x:%02x:%02x]", d->mApSrnMacAddress[0],
      |         ^
gps/core/data-items/DataItemConcreteTypes.cpp:514:9: error: 'snprintf'
will always be truncated; specified size is 10, but format string
expands to at least 20 [-Werror,-Wfortify-source]
  514 |         snprintf(t, sizeof(t),
        "[%02x:%02x:%02x:%02x:%02x:%02x]", d->mApSrnMacAddress[0],
      |         ^
2 errors generated.

Change-Id: I37188e7497f7ade97648fb41e2becd73f6b559a9
This commit is contained in:
Michael Bestas 2024-06-13 20:24:53 +03:00 committed by Michael Bestas
parent 81aaabbfbf
commit 7bb9e7f4df
No known key found for this signature in database
GPG key ID: CC95044519BE6669

View file

@ -458,11 +458,11 @@ void BtLeDeviceScanDetailsDataItem::stringify(string& valueStr) {
valueStr += d->mApSrnRssi;
valueStr += ", ";
char t[10];
memset (t, '\0', 10);
char t[20];
memset (t, '\0', 20);
valueStr += BTLESCANDETAILS_FIELD_MAC;
valueStr += ": ";
snprintf(t, 10, "[%02x:%02x:%02x:%02x:%02x:%02x]", d->mApSrnMacAddress[0],
snprintf(t, 20, "[%02x:%02x:%02x:%02x:%02x:%02x]", d->mApSrnMacAddress[0],
d->mApSrnMacAddress[1], d->mApSrnMacAddress[2], d->mApSrnMacAddress[3],
d->mApSrnMacAddress[4], d->mApSrnMacAddress[5]);
valueStr += t;
@ -507,11 +507,11 @@ void BtDeviceScanDetailsDataItem::stringify(string& valueStr) {
valueStr += d->mApSrnRssi;
valueStr += ", ";
char t[10];
memset (t, '\0', 10);
char t[20];
memset (t, '\0', 20);
valueStr += BTSCANDETAILS_FIELD_MAC;
valueStr += ": ";
snprintf(t, 10, "[%02x:%02x:%02x:%02x:%02x:%02x]", d->mApSrnMacAddress[0],
snprintf(t, 20, "[%02x:%02x:%02x:%02x:%02x:%02x]", d->mApSrnMacAddress[0],
d->mApSrnMacAddress[1], d->mApSrnMacAddress[2], d->mApSrnMacAddress[3],
d->mApSrnMacAddress[4], d->mApSrnMacAddress[5]);
valueStr += t;