diff options
author | Michael Tuexen <tuexen@FreeBSD.org> | 2020-05-18 10:07:01 +0000 |
---|---|---|
committer | Michael Tuexen <tuexen@FreeBSD.org> | 2020-05-18 10:07:01 +0000 |
commit | e708e2a4f4a274e48e8b15da3b03c21d2dda1892 (patch) | |
tree | fd3af08a95f6fdb3431ac1131403f692068344b6 /sys/netinet/sctp_pcb.c | |
parent | 5f148eeefda57c39b5c650b4a29bf195c461e3a3 (diff) | |
download | src-e708e2a4f4a274e48e8b15da3b03c21d2dda1892.tar.gz src-e708e2a4f4a274e48e8b15da3b03c21d2dda1892.zip |
Handle failures of snprintf().
MFC after: 3 days
Notes
Notes:
svn path=/head/; revision=361209
Diffstat (limited to 'sys/netinet/sctp_pcb.c')
-rw-r--r-- | sys/netinet/sctp_pcb.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c index 3ca8d32f4c41..6a2b558729df 100644 --- a/sys/netinet/sctp_pcb.c +++ b/sys/netinet/sctp_pcb.c @@ -544,9 +544,13 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index, atomic_add_int(&vrf->refcount, 1); sctp_ifnp->ifn_mtu = SCTP_GATHER_MTU_FROM_IFN_INFO(ifn, ifn_index, addr->sa_family); if (if_name != NULL) { - snprintf(sctp_ifnp->ifn_name, SCTP_IFNAMSIZ, "%s", if_name); + if (snprintf(sctp_ifnp->ifn_name, SCTP_IFNAMSIZ, "%s", if_name) < 0) { + sctp_ifnp->ifn_name[0] = '\0'; + } } else { - snprintf(sctp_ifnp->ifn_name, SCTP_IFNAMSIZ, "%s", "unknown"); + if (snprintf(sctp_ifnp->ifn_name, SCTP_IFNAMSIZ, "%s", "unknown") < 0) { + sctp_ifnp->ifn_name[0] = '\0'; + } } hash_ifn_head = &SCTP_BASE_INFO(vrf_ifn_hash)[(ifn_index & SCTP_BASE_INFO(vrf_ifn_hashmark))]; LIST_INIT(&sctp_ifnp->ifalist); @@ -6221,8 +6225,10 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m, * in setup state we * abort this guy */ - snprintf(msg, sizeof(msg), - "%s:%d at %s", __FILE__, __LINE__, __func__); + if (snprintf(msg, sizeof(msg), + "%s:%d at %s", __FILE__, __LINE__, __func__) < 0) { + msg[0] = '\0'; + } op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), msg); sctp_abort_an_association(stcb_tmp->sctp_ep, @@ -6321,8 +6327,10 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m, * in setup state we * abort this guy */ - snprintf(msg, sizeof(msg), - "%s:%d at %s", __FILE__, __LINE__, __func__); + if (snprintf(msg, sizeof(msg), + "%s:%d at %s", __FILE__, __LINE__, __func__) < 0) { + msg[0] = '\0'; + } op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), msg); sctp_abort_an_association(stcb_tmp->sctp_ep, |