Wrap osmo_strlcpy() calls
Using following semantic patch:
@@ expression A, B, C; @@
- osmo_strlcpy(A, B, sizeof(A));
+ OSMO_STRLCPY_ARRAY(A, B);
Which was applied using following command:
spatch --dir src -I src --sp-file strlcpy.spatch --in-place --recursive-includes
All the calls to osmo_strlcpy() which use destination buffer obtained
via sizeof() were replaced with the corresponding wrapper macro.
Change-Id: I67b482dedfa11237ac21894fc5930039e12434ab
Related: OS#2864
diff --git a/src/libmsc/smpp_openbsc.c b/src/libmsc/smpp_openbsc.c
index b0469f9..c12db5f 100644
--- a/src/libmsc/smpp_openbsc.c
+++ b/src/libmsc/smpp_openbsc.c
@@ -152,16 +152,15 @@
sms->dst.ton = submit->dest_addr_ton;
sms->dst.npi = submit->dest_addr_npi;
if (dest)
- osmo_strlcpy(sms->dst.addr, dest->msisdn, sizeof(sms->dst.addr));
+ OSMO_STRLCPY_ARRAY(sms->dst.addr, dest->msisdn);
else
- osmo_strlcpy(sms->dst.addr, (const char *)submit->destination_addr,
- sizeof(sms->dst.addr));
+ OSMO_STRLCPY_ARRAY(sms->dst.addr,
+ (const char *)submit->destination_addr);
/* fill in the source address */
sms->src.ton = submit->source_addr_ton;
sms->src.npi = submit->source_addr_npi;
- osmo_strlcpy(sms->src.addr, (char *)submit->source_addr,
- sizeof(sms->src.addr));
+ OSMO_STRLCPY_ARRAY(sms->src.addr, (char *)submit->source_addr);
if (submit->esm_class == SMPP34_DELIVERY_ACK)
sms->is_report = true;