Module: kamailio Branch: master Commit: 33c40170e73adc71e2ad66d8dbb6c776b771ce5d URL: https://github.com/kamailio/kamailio/commit/33c40170e73adc71e2ad66d8dbb6c776b771ce5d
Author: Daniel-Constantin Mierla <[email protected]> Committer: Daniel-Constantin Mierla <[email protected]> Date: 2022-01-11T08:19:06+01:00 presence: utils - use memcpy instead of strncpy for coherence --- Modified: src/modules/presence/utils_func.h --- Diff: https://github.com/kamailio/kamailio/commit/33c40170e73adc71e2ad66d8dbb6c776b771ce5d.diff Patch: https://github.com/kamailio/kamailio/commit/33c40170e73adc71e2ad66d8dbb6c776b771ce5d.patch --- diff --git a/src/modules/presence/utils_func.h b/src/modules/presence/utils_func.h index 27fcc07d0a..5c5d58b22a 100644 --- a/src/modules/presence/utils_func.h +++ b/src/modules/presence/utils_func.h @@ -137,7 +137,7 @@ static inline int ps_fill_local_contact(struct sip_msg *msg, str *contact) contact->len += 1; p += 1; } - strncpy(p, ip.s, ip.len); + memcpy(p, ip.s, ip.len); contact->len += ip.len; p += ip.len; if(msg->rcv.bind_address->address.af == AF_INET6) { @@ -145,7 +145,7 @@ static inline int ps_fill_local_contact(struct sip_msg *msg, str *contact) contact->len += 1; p += 1; } - if(contact->len > LCONTACT_BUF_SIZE - 21) { + if(contact->len > LCONTACT_BUF_SIZE - 22) { LM_ERR("buffer overflow\n"); goto error; } @@ -156,8 +156,9 @@ static inline int ps_fill_local_contact(struct sip_msg *msg, str *contact) } contact->len += len; p += len; - strncpy(p, proto, plen); + memcpy(p, proto, plen); contact->len += plen; + contact->s[contact->len] = '\0'; return 0; error: _______________________________________________ Kamailio (SER) - Development Mailing List [email protected] https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
