fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-msc/+/37239?usp=email )


Change subject: utils/smpp_mirror: use OSMO_STRLCPY_ARRAY, fix 
-Wstringop-overflow
......................................................................

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(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/39/37239/1

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 https://gerrit.osmocom.org/c/osmo-msc/+/37239?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Change-Id: If1df370fbfbca0953abf83ea1840d8bf8a0118be
Gerrit-Change-Number: 37239
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <[email protected]>
Gerrit-MessageType: newchange

Reply via email to