Don't copy uninitialized memory. Also simplify the comparison
of interface names. MFC after: 3 days.
This commit is contained in:
parent
56be1b9a7a
commit
eb20220e9b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=227486
@ -559,9 +559,9 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index,
|
|||||||
atomic_add_int(&vrf->refcount, 1);
|
atomic_add_int(&vrf->refcount, 1);
|
||||||
sctp_ifnp->ifn_mtu = SCTP_GATHER_MTU_FROM_IFN_INFO(ifn, ifn_index, addr->sa_family);
|
sctp_ifnp->ifn_mtu = SCTP_GATHER_MTU_FROM_IFN_INFO(ifn, ifn_index, addr->sa_family);
|
||||||
if (if_name != NULL) {
|
if (if_name != NULL) {
|
||||||
memcpy(sctp_ifnp->ifn_name, if_name, SCTP_IFNAMSIZ);
|
snprintf(sctp_ifnp->ifn_name, SCTP_IFNAMSIZ, "%s", if_name);
|
||||||
} else {
|
} else {
|
||||||
memcpy(sctp_ifnp->ifn_name, "unknown", min(7, SCTP_IFNAMSIZ));
|
snprintf(sctp_ifnp->ifn_name, SCTP_IFNAMSIZ, "%s", "unknown");
|
||||||
}
|
}
|
||||||
hash_ifn_head = &SCTP_BASE_INFO(vrf_ifn_hash)[(ifn_index & SCTP_BASE_INFO(vrf_ifn_hashmark))];
|
hash_ifn_head = &SCTP_BASE_INFO(vrf_ifn_hash)[(ifn_index & SCTP_BASE_INFO(vrf_ifn_hashmark))];
|
||||||
LIST_INIT(&sctp_ifnp->ifalist);
|
LIST_INIT(&sctp_ifnp->ifalist);
|
||||||
@ -768,19 +768,9 @@ sctp_del_addr_from_vrf(uint32_t vrf_id, struct sockaddr *addr,
|
|||||||
* panda who might recycle indexes fast.
|
* panda who might recycle indexes fast.
|
||||||
*/
|
*/
|
||||||
if (if_name) {
|
if (if_name) {
|
||||||
int len1, len2;
|
if (strncmp(if_name, sctp_ifap->ifn_p->ifn_name, SCTP_IFNAMSIZ) == 0) {
|
||||||
|
/* They match its a correct delete */
|
||||||
len1 = min(SCTP_IFNAMSIZ, strlen(if_name));
|
valid = 1;
|
||||||
len2 = min(SCTP_IFNAMSIZ, strlen(sctp_ifap->ifn_p->ifn_name));
|
|
||||||
if (len1 && len2 && (len1 == len2)) {
|
|
||||||
/* we can compare them */
|
|
||||||
if (strncmp(if_name, sctp_ifap->ifn_p->ifn_name, len1) == 0) {
|
|
||||||
/*
|
|
||||||
* They match its a correct
|
|
||||||
* delete
|
|
||||||
*/
|
|
||||||
valid = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
|
Loading…
Reference in New Issue
Block a user