fixeria submitted this change.

View Change


Approvals: neels: Looks good to me, but someone else must approve Jenkins Builder: Verified pespin: Looks good to me, approved
utils/smpp_mirror: use OSMO_STRLCPY_ARRAY, fix -Wstringop-overflow

This patch fixes a warning printed by gcc 14.1.1:

CC smpp_mirror-smpp_mirror.o
CCLD smpp_mirror
In function 'snprintf',
inlined from 'bind_transceiver' at smpp_mirror.c:121:2,
inlined from 'smpp_esme_init' at smpp_mirror.c:258:9,
inlined from 'main' at smpp_mirror.c:299:7:
/usr/include/bits/stdio2.h:54:10: warning: '__builtin___snprintf_chk'
specified bound 16 exceeds destination size 9
[-Wstringop-overflow=]
54 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
| ^

Take a chance to replace all snprintf() calls with OSMO_STRLCPY_ARRAY.

Change-Id: If1df370fbfbca0953abf83ea1840d8bf8a0118be
---
M src/utils/smpp_mirror.c
1 file changed, 30 insertions(+), 5 deletions(-)

diff --git a/src/utils/smpp_mirror.c b/src/utils/smpp_mirror.c
index 3356468..340e94f 100644
--- a/src/utils/smpp_mirror.c
+++ b/src/utils/smpp_mirror.c
@@ -117,9 +117,9 @@
memset(&bind, 0, sizeof(bind));
bind.command_id = BIND_TRANSCEIVER;
bind.sequence_number = esme_inc_seq_nr(esme);
- snprintf((char *)bind.system_id, SMPP_SYS_ID_LEN + 1, "%s", esme->system_id);
- snprintf((char *)bind.password, SMPP_SYS_ID_LEN + 1, "%s", esme->password);
- snprintf((char *)bind.system_type, sizeof(bind.system_type), "mirror");
+ OSMO_STRLCPY_ARRAY(bind.system_id, esme->system_id);
+ OSMO_STRLCPY_ARRAY(bind.password, esme->password);
+ OSMO_STRLCPY_ARRAY(bind.system_type, "mirror");
bind.interface_version = esme->smpp_version;

return PACK_AND_SEND(esme, &bind);
@@ -287,8 +287,8 @@
if (!esme)
exit(2);

- snprintf((char *) esme->system_id, sizeof(esme->system_id), "mirror");
- snprintf((char *) esme->password, sizeof(esme->password), "mirror");
+ OSMO_STRLCPY_ARRAY(esme->system_id, "mirror");
+ OSMO_STRLCPY_ARRAY(esme->password, "mirror");
esme->smpp_version = 0x34;

if (argc >= 2)

To view, visit change 37239. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Change-Id: If1df370fbfbca0953abf83ea1840d8bf8a0118be
Gerrit-Change-Number: 37239
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: neels <nhofmeyr@sysmocom.de>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>
Gerrit-MessageType: merged