summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/netgraph/ng_base.c41
-rw-r--r--sys/netgraph/ng_bpf.h12
-rw-r--r--sys/netgraph/ng_bridge.c2
-rw-r--r--sys/netgraph/ng_device.c2
-rw-r--r--sys/netgraph/ng_etf.h2
-rw-r--r--sys/netgraph/ng_ksocket.c2
-rw-r--r--sys/netgraph/ng_message.h30
-rw-r--r--sys/netgraph/ng_parse.c10
-rw-r--r--sys/netgraph/ng_parse.h10
-rw-r--r--sys/netgraph/ng_pppoe.c4
-rw-r--r--sys/netgraph/ng_pppoe.h4
-rw-r--r--sys/netgraph/ng_socket.c10
12 files changed, 64 insertions, 65 deletions
diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c
index 7895617..878ec88 100644
--- a/sys/netgraph/ng_base.c
+++ b/sys/netgraph/ng_base.c
@@ -549,7 +549,7 @@ ng_make_node(const char *typename, node_p *nodepp)
/* Locate the node type */
if ((type = ng_findtype(typename)) == NULL) {
- char filename[NG_TYPELEN + 4];
+ char filename[NG_TYPESIZ + 3];
linker_file_t lf;
int error;
@@ -816,7 +816,7 @@ ng_name_node(node_p node, const char *name)
node_p node2;
/* Check the name is valid */
- for (i = 0; i < NG_NODELEN + 1; i++) {
+ for (i = 0; i < NG_NODESIZ; i++) {
if (name[i] == '\0' || name[i] == '.' || name[i] == ':')
break;
}
@@ -837,7 +837,7 @@ ng_name_node(node_p node, const char *name)
}
/* copy it */
- strncpy(NG_NODE_NAME(node), name, NG_NODELEN);
+ strlcpy(NG_NODE_NAME(node), name, NG_NODESIZ);
return (0);
}
@@ -986,7 +986,7 @@ ng_add_hook(node_p node, const char *name, hook_p *hookp)
NG_NODE_REF(node); /* each hook counts as a reference */
/* Set hook name */
- strncpy(NG_HOOK_NAME(hook), name, NG_HOOKLEN);
+ strlcpy(NG_HOOK_NAME(hook), name, NG_HOOKSIZ);
/*
* Check if the node type code has something to say about it
@@ -1145,7 +1145,7 @@ ng_newtype(struct ng_type *tp)
/* Check version and type name fields */
if ((tp->version != NG_ABI_VERSION)
|| (namelen == 0)
- || (namelen > NG_TYPELEN)) {
+ || (namelen >= NG_TYPESIZ)) {
TRAP_ERROR();
return (EINVAL);
}
@@ -1349,7 +1349,7 @@ ng_con_nodes(node_p node, const char *name, node_p node2, const char *name2)
NG_HOOK_REF(hook); /* Add a ref for the peer to each*/
NG_HOOK_REF(hook2);
hook2->hk_node = &ng_deadnode;
- strncpy(NG_HOOK_NAME(hook2), name2, NG_HOOKLEN);
+ strlcpy(NG_HOOK_NAME(hook2), name2, NG_HOOKSIZ);
/*
* Queue the function above.
@@ -1569,7 +1569,7 @@ int
ng_path2noderef(node_p here, const char *address,
node_p *destp, hook_p *lasthook)
{
- char fullpath[NG_PATHLEN + 1];
+ char fullpath[NG_PATHSIZ];
char *nodename, *path, pbuf[2];
node_p node, oldnode;
char *cp;
@@ -2553,8 +2553,8 @@ ng_generic_msg(node_p here, item_p item, hook_p lasthook)
/* Fill in node info */
ni = (struct nodeinfo *) resp->data;
if (NG_NODE_HAS_NAME(here))
- strncpy(ni->name, NG_NODE_NAME(here), NG_NODELEN);
- strncpy(ni->type, here->nd_type->name, NG_TYPELEN);
+ strcpy(ni->name, NG_NODE_NAME(here));
+ strcpy(ni->type, here->nd_type->name);
ni->id = ng_node2ID(here);
ni->hooks = here->nd_numhooks;
break;
@@ -2578,8 +2578,8 @@ ng_generic_msg(node_p here, item_p item, hook_p lasthook)
/* Fill in node info */
if (NG_NODE_HAS_NAME(here))
- strncpy(ni->name, NG_NODE_NAME(here), NG_NODELEN);
- strncpy(ni->type, here->nd_type->name, NG_TYPELEN);
+ strcpy(ni->name, NG_NODE_NAME(here));
+ strcpy(ni->type, here->nd_type->name);
ni->id = ng_node2ID(here);
/* Cycle through the linked list of hooks */
@@ -2594,14 +2594,13 @@ ng_generic_msg(node_p here, item_p item, hook_p lasthook)
}
if (NG_HOOK_NOT_VALID(hook))
continue;
- strncpy(link->ourhook, NG_HOOK_NAME(hook), NG_HOOKLEN);
- strncpy(link->peerhook,
- NG_PEER_HOOK_NAME(hook), NG_HOOKLEN);
+ strcpy(link->ourhook, NG_HOOK_NAME(hook));
+ strcpy(link->peerhook, NG_PEER_HOOK_NAME(hook));
if (NG_PEER_NODE_NAME(hook)[0] != '\0')
- strncpy(link->nodeinfo.name,
- NG_PEER_NODE_NAME(hook), NG_NODELEN);
- strncpy(link->nodeinfo.type,
- NG_PEER_NODE(hook)->nd_type->name, NG_TYPELEN);
+ strcpy(link->nodeinfo.name,
+ NG_PEER_NODE_NAME(hook));
+ strcpy(link->nodeinfo.type,
+ NG_PEER_NODE(hook)->nd_type->name);
link->nodeinfo.id = ng_node2ID(NG_PEER_NODE(hook));
link->nodeinfo.hooks = NG_PEER_NODE(hook)->nd_numhooks;
ni->hooks++;
@@ -2652,8 +2651,8 @@ ng_generic_msg(node_p here, item_p item, hook_p lasthook)
if (!unnamed && (! NG_NODE_HAS_NAME(node)))
continue;
if (NG_NODE_HAS_NAME(node))
- strncpy(np->name, NG_NODE_NAME(node), NG_NODELEN);
- strncpy(np->type, node->nd_type->name, NG_TYPELEN);
+ strcpy(np->name, NG_NODE_NAME(node));
+ strcpy(np->type, node->nd_type->name);
np->id = ng_node2ID(node);
np->hooks = node->nd_numhooks;
nl->numnames++;
@@ -2695,7 +2694,7 @@ ng_generic_msg(node_p here, item_p item, hook_p lasthook)
__func__, "types");
break;
}
- strncpy(tp->type_name, type->name, NG_TYPELEN);
+ strcpy(tp->type_name, type->name);
tp->numnodes = type->refs - 1; /* don't count list */
tl->numtypes++;
}
diff --git a/sys/netgraph/ng_bpf.h b/sys/netgraph/ng_bpf.h
index 2362dd1..478dd65 100644
--- a/sys/netgraph/ng_bpf.h
+++ b/sys/netgraph/ng_bpf.h
@@ -49,9 +49,9 @@
/* Program structure for one hook */
struct ng_bpf_hookprog {
- char thisHook[NG_HOOKLEN+1]; /* name of hook */
- char ifMatch[NG_HOOKLEN+1]; /* match dest hook */
- char ifNotMatch[NG_HOOKLEN+1]; /* !match dest hook */
+ char thisHook[NG_HOOKSIZ]; /* name of hook */
+ char ifMatch[NG_HOOKSIZ]; /* match dest hook */
+ char ifNotMatch[NG_HOOKSIZ]; /* !match dest hook */
int32_t bpf_prog_len; /* #isns in program */
struct bpf_insn bpf_prog[]; /* bpf program */
};
@@ -94,9 +94,9 @@ struct ng_bpf_hookstat {
enum {
NGM_BPF_SET_PROGRAM = 1, /* supply a struct ng_bpf_hookprog */
NGM_BPF_GET_PROGRAM, /* returns a struct ng_bpf_hookprog */
- NGM_BPF_GET_STATS, /* supply name as char[NG_HOOKLEN+1] */
- NGM_BPF_CLR_STATS, /* supply name as char[NG_HOOKLEN+1] */
- NGM_BPF_GETCLR_STATS, /* supply name as char[NG_HOOKLEN+1] */
+ NGM_BPF_GET_STATS, /* supply name as char[NG_HOOKSIZ] */
+ NGM_BPF_CLR_STATS, /* supply name as char[NG_HOOKSIZ] */
+ NGM_BPF_GETCLR_STATS, /* supply name as char[NG_HOOKSIZ] */
};
#endif /* _NETGRAPH_NG_BPF_H_ */
diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c
index b7f47fc..6db3d8b 100644
--- a/sys/netgraph/ng_bridge.c
+++ b/sys/netgraph/ng_bridge.c
@@ -1052,7 +1052,7 @@ ng_bridge_timeout(void *arg)
static const char *
ng_bridge_nodename(node_p node)
{
- static char name[NG_NODELEN+1];
+ static char name[NG_NODESIZ];
if (NG_NODE_NAME(node) != NULL)
snprintf(name, sizeof(name), "%s", NG_NODE_NAME(node));
diff --git a/sys/netgraph/ng_device.c b/sys/netgraph/ng_device.c
index e679d4e..b05c515 100644
--- a/sys/netgraph/ng_device.c
+++ b/sys/netgraph/ng_device.c
@@ -96,7 +96,7 @@ struct ngd_softc {
SLIST_HEAD(, ngd_connection) head;
node_p node;
- char nodename[NG_NODELEN + 1];
+ char nodename[NG_NODESIZ];
} ngd_softc;
/* the per connection receiving queue maximum */
diff --git a/sys/netgraph/ng_etf.h b/sys/netgraph/ng_etf.h
index 5d4edd7..5bf19c3 100644
--- a/sys/netgraph/ng_etf.h
+++ b/sys/netgraph/ng_etf.h
@@ -72,7 +72,7 @@ struct ng_etfstat {
/* This structure is returned by the NGM_ETF_GET_STATUS command */
struct ng_etffilter {
- char matchhook[NG_HOOKLEN + 1]; /* hook name */
+ char matchhook[NG_HOOKSIZ]; /* hook name */
u_int16_t ethertype; /* this ethertype to this hook */
};
diff --git a/sys/netgraph/ng_ksocket.c b/sys/netgraph/ng_ksocket.c
index 5fd8b1a..0f8cbc0 100644
--- a/sys/netgraph/ng_ksocket.c
+++ b/sys/netgraph/ng_ksocket.c
@@ -551,7 +551,7 @@ ng_ksocket_newhook(node_p node, hook_p hook, const char *name0)
{
struct thread *td = curthread ? curthread : &thread0; /* XXX broken */
const priv_p priv = NG_NODE_PRIVATE(node);
- char *s1, *s2, name[NG_HOOKLEN+1];
+ char *s1, *s2, name[NG_HOOKSIZ];
int family, type, protocol, error;
/* Check if we're already connected */
diff --git a/sys/netgraph/ng_message.h b/sys/netgraph/ng_message.h
index ede2b95..4a5f479 100644
--- a/sys/netgraph/ng_message.h
+++ b/sys/netgraph/ng_message.h
@@ -71,7 +71,7 @@ struct ng_mesg {
u_int32_t token; /* match with reply */
u_int32_t typecookie; /* node's type cookie */
u_int32_t cmd; /* command identifier */
- u_char cmdstr[NG_CMDSTRLEN+1]; /* cmd string + \0 */
+ u_char cmdstr[NG_CMDSTRSIZ]; /* cmd string + \0 */
} header;
char data[]; /* placeholder for actual data */
};
@@ -162,9 +162,9 @@ struct ng_mesg {
#define NGM_SET_FLOW_MANAGER 48 /* send flow control here */
/* Structure used for NGM_MKPEER */
struct ngm_mkpeer {
- char type[NG_TYPELEN + 1]; /* peer type */
- char ourhook[NG_HOOKLEN + 1]; /* hook name */
- char peerhook[NG_HOOKLEN + 1]; /* peer hook name */
+ char type[NG_TYPESIZ]; /* peer type */
+ char ourhook[NG_HOOKSIZ]; /* hook name */
+ char peerhook[NG_HOOKSIZ]; /* peer hook name */
};
/* Keep this in sync with the above structure definition */
@@ -177,9 +177,9 @@ struct ngm_mkpeer {
/* Structure used for NGM_CONNECT */
struct ngm_connect {
- char path[NG_PATHLEN + 1]; /* peer path */
- char ourhook[NG_HOOKLEN + 1]; /* hook name */
- char peerhook[NG_HOOKLEN + 1]; /* peer hook name */
+ char path[NG_PATHSIZ]; /* peer path */
+ char ourhook[NG_HOOKSIZ]; /* hook name */
+ char peerhook[NG_HOOKSIZ]; /* peer hook name */
};
/* Keep this in sync with the above structure definition */
@@ -192,7 +192,7 @@ struct ngm_connect {
/* Structure used for NGM_NAME */
struct ngm_name {
- char name[NG_NODELEN + 1]; /* node name */
+ char name[NG_NODESIZ]; /* node name */
};
/* Keep this in sync with the above structure definition */
@@ -203,7 +203,7 @@ struct ngm_name {
/* Structure used for NGM_RMHOOK */
struct ngm_rmhook {
- char ourhook[NG_HOOKLEN + 1]; /* hook name */
+ char ourhook[NG_HOOKSIZ]; /* hook name */
};
/* Keep this in sync with the above structure definition */
@@ -214,8 +214,8 @@ struct ngm_rmhook {
/* Structure used for NGM_NODEINFO */
struct nodeinfo {
- char name[NG_NODELEN + 1]; /* node name (if any) */
- char type[NG_TYPELEN + 1]; /* peer type */
+ char name[NG_NODESIZ]; /* node name (if any) */
+ char type[NG_TYPESIZ]; /* peer type */
ng_ID_t id; /* unique identifier */
u_int32_t hooks; /* number of active hooks */
};
@@ -231,8 +231,8 @@ struct nodeinfo {
/* Structure used for NGM_LISTHOOKS */
struct linkinfo {
- char ourhook[NG_HOOKLEN + 1]; /* hook name */
- char peerhook[NG_HOOKLEN + 1]; /* peer hook */
+ char ourhook[NG_HOOKSIZ]; /* hook name */
+ char peerhook[NG_HOOKSIZ]; /* peer hook */
struct nodeinfo nodeinfo;
};
@@ -271,8 +271,8 @@ struct namelist {
/* Structure used for NGM_LISTTYPES */
struct typeinfo {
- char type_name[NG_TYPELEN + 1]; /* name of type */
- u_int32_t numnodes; /* number alive */
+ char type_name[NG_TYPESIZ]; /* name of type */
+ u_int32_t numnodes; /* number alive */
};
/* Keep this in sync with the above structure definition */
diff --git a/sys/netgraph/ng_parse.c b/sys/netgraph/ng_parse.c
index 58389e8..db77535 100644
--- a/sys/netgraph/ng_parse.c
+++ b/sys/netgraph/ng_parse.c
@@ -840,7 +840,7 @@ const struct ng_parse_type ng_parse_fixedstring_type = {
};
const struct ng_parse_fixedstring_info ng_parse_nodebuf_info = {
- NG_NODELEN + 1
+ NG_NODESIZ
};
const struct ng_parse_type ng_parse_nodebuf_type = {
&ng_parse_fixedstring_type,
@@ -848,7 +848,7 @@ const struct ng_parse_type ng_parse_nodebuf_type = {
};
const struct ng_parse_fixedstring_info ng_parse_hookbuf_info = {
- NG_HOOKLEN + 1
+ NG_HOOKSIZ
};
const struct ng_parse_type ng_parse_hookbuf_type = {
&ng_parse_fixedstring_type,
@@ -856,7 +856,7 @@ const struct ng_parse_type ng_parse_hookbuf_type = {
};
const struct ng_parse_fixedstring_info ng_parse_pathbuf_info = {
- NG_PATHLEN + 1
+ NG_PATHSIZ
};
const struct ng_parse_type ng_parse_pathbuf_type = {
&ng_parse_fixedstring_type,
@@ -864,7 +864,7 @@ const struct ng_parse_type ng_parse_pathbuf_type = {
};
const struct ng_parse_fixedstring_info ng_parse_typebuf_info = {
- NG_TYPELEN + 1
+ NG_TYPESIZ
};
const struct ng_parse_type ng_parse_typebuf_type = {
&ng_parse_fixedstring_type,
@@ -872,7 +872,7 @@ const struct ng_parse_type ng_parse_typebuf_type = {
};
const struct ng_parse_fixedstring_info ng_parse_cmdbuf_info = {
- NG_CMDSTRLEN + 1
+ NG_CMDSTRSIZ
};
const struct ng_parse_type ng_parse_cmdbuf_type = {
&ng_parse_fixedstring_type,
diff --git a/sys/netgraph/ng_parse.h b/sys/netgraph/ng_parse.h
index e8df669..9155551 100644
--- a/sys/netgraph/ng_parse.h
+++ b/sys/netgraph/ng_parse.h
@@ -404,11 +404,11 @@ extern const struct ng_parse_type ng_parse_sizedstring_type;
/*
* COMMONLY USED BOUNDED LENGTH STRING TYPES
*/
-extern const struct ng_parse_type ng_parse_nodebuf_type; /* NG_NODELEN + 1 */
-extern const struct ng_parse_type ng_parse_hookbuf_type; /* NG_HOOKLEN + 1 */
-extern const struct ng_parse_type ng_parse_pathbuf_type; /* NG_PATHLEN + 1 */
-extern const struct ng_parse_type ng_parse_typebuf_type; /* NG_TYPELEN + 1 */
-extern const struct ng_parse_type ng_parse_cmdbuf_type; /* NG_CMDSTRLEN + 1 */
+extern const struct ng_parse_type ng_parse_nodebuf_type; /* NG_NODESIZ */
+extern const struct ng_parse_type ng_parse_hookbuf_type; /* NG_HOOKSIZ */
+extern const struct ng_parse_type ng_parse_pathbuf_type; /* NG_PATHSIZ */
+extern const struct ng_parse_type ng_parse_typebuf_type; /* NG_TYPESIZ */
+extern const struct ng_parse_type ng_parse_cmdbuf_type; /* NG_CMDSTRSIZ */
/*
* INTEGER TYPES
diff --git a/sys/netgraph/ng_pppoe.c b/sys/netgraph/ng_pppoe.c
index fb379b3..ba87b5d 100644
--- a/sys/netgraph/ng_pppoe.c
+++ b/sys/netgraph/ng_pppoe.c
@@ -917,7 +917,7 @@ send_acname(sessp sp, const struct pppoe_tag *tag)
return (ENOMEM);
sts = (struct ngpppoe_sts *)msg->data;
- tlen = min(NG_HOOKLEN, ntohs(tag->tag_len));
+ tlen = min(NG_HOOKSIZ - 1, ntohs(tag->tag_len));
strncpy(sts->hook, tag->tag_data, tlen);
sts->hook[tlen] = '\0';
NG_SEND_MSG_ID(error, NG_HOOK_NODE(sp->hook), msg, sp->creator, 0);
@@ -1763,7 +1763,7 @@ AAA
if (msg == NULL)
return (ENOMEM);
sts = (struct ngpppoe_sts *)msg->data;
- strncpy(sts->hook, NG_HOOK_NAME(sp->hook), NG_HOOKLEN + 1);
+ strncpy(sts->hook, NG_HOOK_NAME(sp->hook), NG_HOOKSIZ);
NG_SEND_MSG_ID(error, NG_HOOK_NODE(sp->hook), msg, sp->creator, 0);
return (error);
}
diff --git a/sys/netgraph/ng_pppoe.h b/sys/netgraph/ng_pppoe.h
index 413308b..7eb4594 100644
--- a/sys/netgraph/ng_pppoe.h
+++ b/sys/netgraph/ng_pppoe.h
@@ -115,7 +115,7 @@ struct ngpppoestat {
* and begin negotiation.
*/
struct ngpppoe_init_data {
- char hook[NG_HOOKLEN + 1]; /* hook to monitor on */
+ char hook[NG_HOOKSIZ]; /* hook to monitor on */
u_int16_t data_len; /* Length of the service name */
char data[0]; /* init data goes here */
};
@@ -133,7 +133,7 @@ struct ngpppoe_init_data {
* to whoever requested the connection. (close may use this too).
*/
struct ngpppoe_sts {
- char hook[NG_HOOKLEN + 1]; /* hook associated with event session */
+ char hook[NG_HOOKSIZ]; /* hook associated with event session */
};
/* Keep this in sync with the above structure definition */
diff --git a/sys/netgraph/ng_socket.c b/sys/netgraph/ng_socket.c
index 3498f47..3ce992e 100644
--- a/sys/netgraph/ng_socket.c
+++ b/sys/netgraph/ng_socket.c
@@ -346,7 +346,7 @@ ngd_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
struct sockaddr_ng *const sap = (struct sockaddr_ng *) addr;
int len, error;
hook_p hook = NULL;
- char hookname[NG_HOOKLEN + 1];
+ char hookname[NG_HOOKSIZ];
if ((pcbp == NULL) || (control != NULL)) {
error = EINVAL;
@@ -373,7 +373,7 @@ ngd_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
*/
hook = LIST_FIRST(&pcbp->sockdata->node->nd_hooks);
} else {
- if (len > NG_HOOKLEN) {
+ if (len >= NG_HOOKSIZ) {
error = EINVAL;
goto release;
}
@@ -698,7 +698,7 @@ ng_bind(struct sockaddr *nam, struct ngpcb *pcbp)
return (EINVAL);
}
if ((sap->sg_len < 4)
- || (sap->sg_len > (NG_NODELEN + 3))
+ || (sap->sg_len > (NG_NODESIZ + 2))
|| (sap->sg_data[0] == '\0')
|| (sap->sg_data[sap->sg_len - 3] != '\0')) {
TRAP_ERROR;
@@ -863,7 +863,7 @@ ngs_rcvdata(hook_p hook, item_p item)
struct ngpcb *const pcbp = priv->datasock;
struct socket *so;
struct sockaddr_ng *addr;
- char *addrbuf[NG_HOOKLEN + 1 + 4];
+ char *addrbuf[NG_HOOKSIZ + 4];
int addrlen;
struct mbuf *m;
@@ -877,7 +877,7 @@ ngs_rcvdata(hook_p hook, item_p item)
so = pcbp->ng_socket;
/* Get the return address into a sockaddr. */
- addrlen = strlen(NG_HOOK_NAME(hook)); /* <= NG_HOOKLEN */
+ addrlen = strlen(NG_HOOK_NAME(hook)); /* <= NG_HOOKSIZ - 1 */
addr = (struct sockaddr_ng *) addrbuf;
addr->sg_len = addrlen + 3;
addr->sg_family = AF_NETGRAPH;
OpenPOWER on IntegriCloud