diff options
author | ru <ru@FreeBSD.org> | 2005-02-03 12:54:18 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2005-02-03 12:54:18 +0000 |
commit | da345be611a15d07672aad7b1ef099682743d154 (patch) | |
tree | b66f024fd9a2f20ec479b101d40cafa5bc69687e /sys/netgraph/atm | |
parent | f1160b7b649adedb8b29ccb019ad854dd39778e3 (diff) | |
download | FreeBSD-src-da345be611a15d07672aad7b1ef099682743d154.zip FreeBSD-src-da345be611a15d07672aad7b1ef099682743d154.tar.gz |
Fixed an off-by-one error when dealing with interface name
(if_xname is NUL-terminated).
Don't waste time making a copy of if_xname in attach().
Diffstat (limited to 'sys/netgraph/atm')
-rw-r--r-- | sys/netgraph/atm/ng_atm.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/sys/netgraph/atm/ng_atm.c b/sys/netgraph/atm/ng_atm.c index 7cfc5f0..4f11ef2 100644 --- a/sys/netgraph/atm/ng_atm.c +++ b/sys/netgraph/atm/ng_atm.c @@ -936,12 +936,12 @@ ng_atm_rcvmsg(node_p node, item_p item, hook_p lasthook) switch (msg->header.cmd) { case NGM_ATM_GET_IFNAME: - NG_MKRESPONSE(resp, msg, IFNAMSIZ + 1, M_NOWAIT); + NG_MKRESPONSE(resp, msg, IFNAMSIZ, M_NOWAIT); if (resp == NULL) { error = ENOMEM; break; } - strlcpy(resp->data, priv->ifp->if_xname, IFNAMSIZ + 1); + strlcpy(resp->data, priv->ifp->if_xname, IFNAMSIZ); break; case NGM_ATM_GET_CONFIG: @@ -1259,24 +1259,21 @@ ng_atm_disconnect(hook_p hook) static void ng_atm_attach(struct ifnet *ifp) { - char name[IFNAMSIZ+1]; node_p node; struct priv *priv; KASSERT(IFP2NG(ifp) == 0, ("%s: node alreay exists?", __FUNCTION__)); - strlcpy(name, ifp->if_xname, sizeof(name)); - if (ng_make_node_common(&ng_atm_typestruct, &node) != 0) { log(LOG_ERR, "%s: can't create node for %s\n", - __FUNCTION__, name); + __FUNCTION__, ifp->if_xname); return; } priv = malloc(sizeof(*priv), M_NETGRAPH, M_NOWAIT | M_ZERO); if (priv == NULL) { log(LOG_ERR, "%s: can't allocate memory for %s\n", - __FUNCTION__, name); + __FUNCTION__, ifp->if_xname); NG_NODE_UNREF(node); return; } @@ -1285,9 +1282,9 @@ ng_atm_attach(struct ifnet *ifp) LIST_INIT(&priv->vccs); IFP2NG_SET(ifp, node); - if (ng_name_node(node, name) != 0) { + if (ng_name_node(node, ifp->if_xname) != 0) { log(LOG_WARNING, "%s: can't name node %s\n", - __FUNCTION__, name); + __FUNCTION__, ifp->if_xname); } } |