Get rid of the deprecated *LEN constants in favour of the new
*SIZ constants that include the trailing \0 byte.
This commit is contained in:
parent
98f2740a9c
commit
14cb10664f
@ -549,7 +549,7 @@ ng_make_node(const char *typename, node_p *nodepp)
|
|||||||
|
|
||||||
/* Locate the node type */
|
/* Locate the node type */
|
||||||
if ((type = ng_findtype(typename)) == NULL) {
|
if ((type = ng_findtype(typename)) == NULL) {
|
||||||
char filename[NG_TYPELEN + 4];
|
char filename[NG_TYPESIZ + 3];
|
||||||
linker_file_t lf;
|
linker_file_t lf;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
@ -816,7 +816,7 @@ ng_name_node(node_p node, const char *name)
|
|||||||
node_p node2;
|
node_p node2;
|
||||||
|
|
||||||
/* Check the name is valid */
|
/* 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] == ':')
|
if (name[i] == '\0' || name[i] == '.' || name[i] == ':')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -837,7 +837,7 @@ ng_name_node(node_p node, const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* copy it */
|
/* copy it */
|
||||||
strncpy(NG_NODE_NAME(node), name, NG_NODELEN);
|
strlcpy(NG_NODE_NAME(node), name, NG_NODESIZ);
|
||||||
|
|
||||||
return (0);
|
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 */
|
NG_NODE_REF(node); /* each hook counts as a reference */
|
||||||
|
|
||||||
/* Set hook name */
|
/* 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
|
* 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 */
|
/* Check version and type name fields */
|
||||||
if ((tp->version != NG_ABI_VERSION)
|
if ((tp->version != NG_ABI_VERSION)
|
||||||
|| (namelen == 0)
|
|| (namelen == 0)
|
||||||
|| (namelen > NG_TYPELEN)) {
|
|| (namelen >= NG_TYPESIZ)) {
|
||||||
TRAP_ERROR();
|
TRAP_ERROR();
|
||||||
return (EINVAL);
|
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(hook); /* Add a ref for the peer to each*/
|
||||||
NG_HOOK_REF(hook2);
|
NG_HOOK_REF(hook2);
|
||||||
hook2->hk_node = &ng_deadnode;
|
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.
|
* Queue the function above.
|
||||||
@ -1569,7 +1569,7 @@ int
|
|||||||
ng_path2noderef(node_p here, const char *address,
|
ng_path2noderef(node_p here, const char *address,
|
||||||
node_p *destp, hook_p *lasthook)
|
node_p *destp, hook_p *lasthook)
|
||||||
{
|
{
|
||||||
char fullpath[NG_PATHLEN + 1];
|
char fullpath[NG_PATHSIZ];
|
||||||
char *nodename, *path, pbuf[2];
|
char *nodename, *path, pbuf[2];
|
||||||
node_p node, oldnode;
|
node_p node, oldnode;
|
||||||
char *cp;
|
char *cp;
|
||||||
@ -2553,8 +2553,8 @@ ng_generic_msg(node_p here, item_p item, hook_p lasthook)
|
|||||||
/* Fill in node info */
|
/* Fill in node info */
|
||||||
ni = (struct nodeinfo *) resp->data;
|
ni = (struct nodeinfo *) resp->data;
|
||||||
if (NG_NODE_HAS_NAME(here))
|
if (NG_NODE_HAS_NAME(here))
|
||||||
strncpy(ni->name, NG_NODE_NAME(here), NG_NODELEN);
|
strcpy(ni->name, NG_NODE_NAME(here));
|
||||||
strncpy(ni->type, here->nd_type->name, NG_TYPELEN);
|
strcpy(ni->type, here->nd_type->name);
|
||||||
ni->id = ng_node2ID(here);
|
ni->id = ng_node2ID(here);
|
||||||
ni->hooks = here->nd_numhooks;
|
ni->hooks = here->nd_numhooks;
|
||||||
break;
|
break;
|
||||||
@ -2578,8 +2578,8 @@ ng_generic_msg(node_p here, item_p item, hook_p lasthook)
|
|||||||
|
|
||||||
/* Fill in node info */
|
/* Fill in node info */
|
||||||
if (NG_NODE_HAS_NAME(here))
|
if (NG_NODE_HAS_NAME(here))
|
||||||
strncpy(ni->name, NG_NODE_NAME(here), NG_NODELEN);
|
strcpy(ni->name, NG_NODE_NAME(here));
|
||||||
strncpy(ni->type, here->nd_type->name, NG_TYPELEN);
|
strcpy(ni->type, here->nd_type->name);
|
||||||
ni->id = ng_node2ID(here);
|
ni->id = ng_node2ID(here);
|
||||||
|
|
||||||
/* Cycle through the linked list of hooks */
|
/* 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))
|
if (NG_HOOK_NOT_VALID(hook))
|
||||||
continue;
|
continue;
|
||||||
strncpy(link->ourhook, NG_HOOK_NAME(hook), NG_HOOKLEN);
|
strcpy(link->ourhook, NG_HOOK_NAME(hook));
|
||||||
strncpy(link->peerhook,
|
strcpy(link->peerhook, NG_PEER_HOOK_NAME(hook));
|
||||||
NG_PEER_HOOK_NAME(hook), NG_HOOKLEN);
|
|
||||||
if (NG_PEER_NODE_NAME(hook)[0] != '\0')
|
if (NG_PEER_NODE_NAME(hook)[0] != '\0')
|
||||||
strncpy(link->nodeinfo.name,
|
strcpy(link->nodeinfo.name,
|
||||||
NG_PEER_NODE_NAME(hook), NG_NODELEN);
|
NG_PEER_NODE_NAME(hook));
|
||||||
strncpy(link->nodeinfo.type,
|
strcpy(link->nodeinfo.type,
|
||||||
NG_PEER_NODE(hook)->nd_type->name, NG_TYPELEN);
|
NG_PEER_NODE(hook)->nd_type->name);
|
||||||
link->nodeinfo.id = ng_node2ID(NG_PEER_NODE(hook));
|
link->nodeinfo.id = ng_node2ID(NG_PEER_NODE(hook));
|
||||||
link->nodeinfo.hooks = NG_PEER_NODE(hook)->nd_numhooks;
|
link->nodeinfo.hooks = NG_PEER_NODE(hook)->nd_numhooks;
|
||||||
ni->hooks++;
|
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)))
|
if (!unnamed && (! NG_NODE_HAS_NAME(node)))
|
||||||
continue;
|
continue;
|
||||||
if (NG_NODE_HAS_NAME(node))
|
if (NG_NODE_HAS_NAME(node))
|
||||||
strncpy(np->name, NG_NODE_NAME(node), NG_NODELEN);
|
strcpy(np->name, NG_NODE_NAME(node));
|
||||||
strncpy(np->type, node->nd_type->name, NG_TYPELEN);
|
strcpy(np->type, node->nd_type->name);
|
||||||
np->id = ng_node2ID(node);
|
np->id = ng_node2ID(node);
|
||||||
np->hooks = node->nd_numhooks;
|
np->hooks = node->nd_numhooks;
|
||||||
nl->numnames++;
|
nl->numnames++;
|
||||||
@ -2695,7 +2694,7 @@ ng_generic_msg(node_p here, item_p item, hook_p lasthook)
|
|||||||
__func__, "types");
|
__func__, "types");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
strncpy(tp->type_name, type->name, NG_TYPELEN);
|
strcpy(tp->type_name, type->name);
|
||||||
tp->numnodes = type->refs - 1; /* don't count list */
|
tp->numnodes = type->refs - 1; /* don't count list */
|
||||||
tl->numtypes++;
|
tl->numtypes++;
|
||||||
}
|
}
|
||||||
|
@ -49,9 +49,9 @@
|
|||||||
|
|
||||||
/* Program structure for one hook */
|
/* Program structure for one hook */
|
||||||
struct ng_bpf_hookprog {
|
struct ng_bpf_hookprog {
|
||||||
char thisHook[NG_HOOKLEN+1]; /* name of hook */
|
char thisHook[NG_HOOKSIZ]; /* name of hook */
|
||||||
char ifMatch[NG_HOOKLEN+1]; /* match dest hook */
|
char ifMatch[NG_HOOKSIZ]; /* match dest hook */
|
||||||
char ifNotMatch[NG_HOOKLEN+1]; /* !match dest hook */
|
char ifNotMatch[NG_HOOKSIZ]; /* !match dest hook */
|
||||||
int32_t bpf_prog_len; /* #isns in program */
|
int32_t bpf_prog_len; /* #isns in program */
|
||||||
struct bpf_insn bpf_prog[]; /* bpf program */
|
struct bpf_insn bpf_prog[]; /* bpf program */
|
||||||
};
|
};
|
||||||
@ -94,9 +94,9 @@ struct ng_bpf_hookstat {
|
|||||||
enum {
|
enum {
|
||||||
NGM_BPF_SET_PROGRAM = 1, /* supply a struct ng_bpf_hookprog */
|
NGM_BPF_SET_PROGRAM = 1, /* supply a struct ng_bpf_hookprog */
|
||||||
NGM_BPF_GET_PROGRAM, /* returns 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_GET_STATS, /* supply name as char[NG_HOOKSIZ] */
|
||||||
NGM_BPF_CLR_STATS, /* supply name as char[NG_HOOKLEN+1] */
|
NGM_BPF_CLR_STATS, /* supply name as char[NG_HOOKSIZ] */
|
||||||
NGM_BPF_GETCLR_STATS, /* supply name as char[NG_HOOKLEN+1] */
|
NGM_BPF_GETCLR_STATS, /* supply name as char[NG_HOOKSIZ] */
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _NETGRAPH_NG_BPF_H_ */
|
#endif /* _NETGRAPH_NG_BPF_H_ */
|
||||||
|
@ -1052,7 +1052,7 @@ ng_bridge_timeout(void *arg)
|
|||||||
static const char *
|
static const char *
|
||||||
ng_bridge_nodename(node_p node)
|
ng_bridge_nodename(node_p node)
|
||||||
{
|
{
|
||||||
static char name[NG_NODELEN+1];
|
static char name[NG_NODESIZ];
|
||||||
|
|
||||||
if (NG_NODE_NAME(node) != NULL)
|
if (NG_NODE_NAME(node) != NULL)
|
||||||
snprintf(name, sizeof(name), "%s", NG_NODE_NAME(node));
|
snprintf(name, sizeof(name), "%s", NG_NODE_NAME(node));
|
||||||
|
@ -96,7 +96,7 @@ struct ngd_softc {
|
|||||||
SLIST_HEAD(, ngd_connection) head;
|
SLIST_HEAD(, ngd_connection) head;
|
||||||
|
|
||||||
node_p node;
|
node_p node;
|
||||||
char nodename[NG_NODELEN + 1];
|
char nodename[NG_NODESIZ];
|
||||||
} ngd_softc;
|
} ngd_softc;
|
||||||
|
|
||||||
/* the per connection receiving queue maximum */
|
/* the per connection receiving queue maximum */
|
||||||
|
@ -72,7 +72,7 @@ struct ng_etfstat {
|
|||||||
|
|
||||||
/* This structure is returned by the NGM_ETF_GET_STATUS command */
|
/* This structure is returned by the NGM_ETF_GET_STATUS command */
|
||||||
struct ng_etffilter {
|
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 */
|
u_int16_t ethertype; /* this ethertype to this hook */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -551,7 +551,7 @@ ng_ksocket_newhook(node_p node, hook_p hook, const char *name0)
|
|||||||
{
|
{
|
||||||
struct thread *td = curthread ? curthread : &thread0; /* XXX broken */
|
struct thread *td = curthread ? curthread : &thread0; /* XXX broken */
|
||||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
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;
|
int family, type, protocol, error;
|
||||||
|
|
||||||
/* Check if we're already connected */
|
/* Check if we're already connected */
|
||||||
|
@ -71,7 +71,7 @@ struct ng_mesg {
|
|||||||
u_int32_t token; /* match with reply */
|
u_int32_t token; /* match with reply */
|
||||||
u_int32_t typecookie; /* node's type cookie */
|
u_int32_t typecookie; /* node's type cookie */
|
||||||
u_int32_t cmd; /* command identifier */
|
u_int32_t cmd; /* command identifier */
|
||||||
u_char cmdstr[NG_CMDSTRLEN+1]; /* cmd string + \0 */
|
u_char cmdstr[NG_CMDSTRSIZ]; /* cmd string + \0 */
|
||||||
} header;
|
} header;
|
||||||
char data[]; /* placeholder for actual data */
|
char data[]; /* placeholder for actual data */
|
||||||
};
|
};
|
||||||
@ -162,9 +162,9 @@ struct ng_mesg {
|
|||||||
#define NGM_SET_FLOW_MANAGER 48 /* send flow control here */
|
#define NGM_SET_FLOW_MANAGER 48 /* send flow control here */
|
||||||
/* Structure used for NGM_MKPEER */
|
/* Structure used for NGM_MKPEER */
|
||||||
struct ngm_mkpeer {
|
struct ngm_mkpeer {
|
||||||
char type[NG_TYPELEN + 1]; /* peer type */
|
char type[NG_TYPESIZ]; /* peer type */
|
||||||
char ourhook[NG_HOOKLEN + 1]; /* hook name */
|
char ourhook[NG_HOOKSIZ]; /* hook name */
|
||||||
char peerhook[NG_HOOKLEN + 1]; /* peer hook name */
|
char peerhook[NG_HOOKSIZ]; /* peer hook name */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Keep this in sync with the above structure definition */
|
/* Keep this in sync with the above structure definition */
|
||||||
@ -177,9 +177,9 @@ struct ngm_mkpeer {
|
|||||||
|
|
||||||
/* Structure used for NGM_CONNECT */
|
/* Structure used for NGM_CONNECT */
|
||||||
struct ngm_connect {
|
struct ngm_connect {
|
||||||
char path[NG_PATHLEN + 1]; /* peer path */
|
char path[NG_PATHSIZ]; /* peer path */
|
||||||
char ourhook[NG_HOOKLEN + 1]; /* hook name */
|
char ourhook[NG_HOOKSIZ]; /* hook name */
|
||||||
char peerhook[NG_HOOKLEN + 1]; /* peer hook name */
|
char peerhook[NG_HOOKSIZ]; /* peer hook name */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Keep this in sync with the above structure definition */
|
/* Keep this in sync with the above structure definition */
|
||||||
@ -192,7 +192,7 @@ struct ngm_connect {
|
|||||||
|
|
||||||
/* Structure used for NGM_NAME */
|
/* Structure used for NGM_NAME */
|
||||||
struct 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 */
|
/* Keep this in sync with the above structure definition */
|
||||||
@ -203,7 +203,7 @@ struct ngm_name {
|
|||||||
|
|
||||||
/* Structure used for NGM_RMHOOK */
|
/* Structure used for NGM_RMHOOK */
|
||||||
struct 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 */
|
/* Keep this in sync with the above structure definition */
|
||||||
@ -214,8 +214,8 @@ struct ngm_rmhook {
|
|||||||
|
|
||||||
/* Structure used for NGM_NODEINFO */
|
/* Structure used for NGM_NODEINFO */
|
||||||
struct nodeinfo {
|
struct nodeinfo {
|
||||||
char name[NG_NODELEN + 1]; /* node name (if any) */
|
char name[NG_NODESIZ]; /* node name (if any) */
|
||||||
char type[NG_TYPELEN + 1]; /* peer type */
|
char type[NG_TYPESIZ]; /* peer type */
|
||||||
ng_ID_t id; /* unique identifier */
|
ng_ID_t id; /* unique identifier */
|
||||||
u_int32_t hooks; /* number of active hooks */
|
u_int32_t hooks; /* number of active hooks */
|
||||||
};
|
};
|
||||||
@ -231,8 +231,8 @@ struct nodeinfo {
|
|||||||
|
|
||||||
/* Structure used for NGM_LISTHOOKS */
|
/* Structure used for NGM_LISTHOOKS */
|
||||||
struct linkinfo {
|
struct linkinfo {
|
||||||
char ourhook[NG_HOOKLEN + 1]; /* hook name */
|
char ourhook[NG_HOOKSIZ]; /* hook name */
|
||||||
char peerhook[NG_HOOKLEN + 1]; /* peer hook */
|
char peerhook[NG_HOOKSIZ]; /* peer hook */
|
||||||
struct nodeinfo nodeinfo;
|
struct nodeinfo nodeinfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -271,8 +271,8 @@ struct namelist {
|
|||||||
|
|
||||||
/* Structure used for NGM_LISTTYPES */
|
/* Structure used for NGM_LISTTYPES */
|
||||||
struct typeinfo {
|
struct typeinfo {
|
||||||
char type_name[NG_TYPELEN + 1]; /* name of type */
|
char type_name[NG_TYPESIZ]; /* name of type */
|
||||||
u_int32_t numnodes; /* number alive */
|
u_int32_t numnodes; /* number alive */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Keep this in sync with the above structure definition */
|
/* Keep this in sync with the above structure definition */
|
||||||
|
@ -840,7 +840,7 @@ const struct ng_parse_type ng_parse_fixedstring_type = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const struct ng_parse_fixedstring_info ng_parse_nodebuf_info = {
|
const struct ng_parse_fixedstring_info ng_parse_nodebuf_info = {
|
||||||
NG_NODELEN + 1
|
NG_NODESIZ
|
||||||
};
|
};
|
||||||
const struct ng_parse_type ng_parse_nodebuf_type = {
|
const struct ng_parse_type ng_parse_nodebuf_type = {
|
||||||
&ng_parse_fixedstring_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 = {
|
const struct ng_parse_fixedstring_info ng_parse_hookbuf_info = {
|
||||||
NG_HOOKLEN + 1
|
NG_HOOKSIZ
|
||||||
};
|
};
|
||||||
const struct ng_parse_type ng_parse_hookbuf_type = {
|
const struct ng_parse_type ng_parse_hookbuf_type = {
|
||||||
&ng_parse_fixedstring_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 = {
|
const struct ng_parse_fixedstring_info ng_parse_pathbuf_info = {
|
||||||
NG_PATHLEN + 1
|
NG_PATHSIZ
|
||||||
};
|
};
|
||||||
const struct ng_parse_type ng_parse_pathbuf_type = {
|
const struct ng_parse_type ng_parse_pathbuf_type = {
|
||||||
&ng_parse_fixedstring_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 = {
|
const struct ng_parse_fixedstring_info ng_parse_typebuf_info = {
|
||||||
NG_TYPELEN + 1
|
NG_TYPESIZ
|
||||||
};
|
};
|
||||||
const struct ng_parse_type ng_parse_typebuf_type = {
|
const struct ng_parse_type ng_parse_typebuf_type = {
|
||||||
&ng_parse_fixedstring_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 = {
|
const struct ng_parse_fixedstring_info ng_parse_cmdbuf_info = {
|
||||||
NG_CMDSTRLEN + 1
|
NG_CMDSTRSIZ
|
||||||
};
|
};
|
||||||
const struct ng_parse_type ng_parse_cmdbuf_type = {
|
const struct ng_parse_type ng_parse_cmdbuf_type = {
|
||||||
&ng_parse_fixedstring_type,
|
&ng_parse_fixedstring_type,
|
||||||
|
@ -404,11 +404,11 @@ extern const struct ng_parse_type ng_parse_sizedstring_type;
|
|||||||
/*
|
/*
|
||||||
* COMMONLY USED BOUNDED LENGTH STRING TYPES
|
* 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_nodebuf_type; /* NG_NODESIZ */
|
||||||
extern const struct ng_parse_type ng_parse_hookbuf_type; /* NG_HOOKLEN + 1 */
|
extern const struct ng_parse_type ng_parse_hookbuf_type; /* NG_HOOKSIZ */
|
||||||
extern const struct ng_parse_type ng_parse_pathbuf_type; /* NG_PATHLEN + 1 */
|
extern const struct ng_parse_type ng_parse_pathbuf_type; /* NG_PATHSIZ */
|
||||||
extern const struct ng_parse_type ng_parse_typebuf_type; /* NG_TYPELEN + 1 */
|
extern const struct ng_parse_type ng_parse_typebuf_type; /* NG_TYPESIZ */
|
||||||
extern const struct ng_parse_type ng_parse_cmdbuf_type; /* NG_CMDSTRLEN + 1 */
|
extern const struct ng_parse_type ng_parse_cmdbuf_type; /* NG_CMDSTRSIZ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* INTEGER TYPES
|
* INTEGER TYPES
|
||||||
|
@ -917,7 +917,7 @@ send_acname(sessp sp, const struct pppoe_tag *tag)
|
|||||||
return (ENOMEM);
|
return (ENOMEM);
|
||||||
|
|
||||||
sts = (struct ngpppoe_sts *)msg->data;
|
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);
|
strncpy(sts->hook, tag->tag_data, tlen);
|
||||||
sts->hook[tlen] = '\0';
|
sts->hook[tlen] = '\0';
|
||||||
NG_SEND_MSG_ID(error, NG_HOOK_NODE(sp->hook), msg, sp->creator, 0);
|
NG_SEND_MSG_ID(error, NG_HOOK_NODE(sp->hook), msg, sp->creator, 0);
|
||||||
@ -1763,7 +1763,7 @@ AAA
|
|||||||
if (msg == NULL)
|
if (msg == NULL)
|
||||||
return (ENOMEM);
|
return (ENOMEM);
|
||||||
sts = (struct ngpppoe_sts *)msg->data;
|
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);
|
NG_SEND_MSG_ID(error, NG_HOOK_NODE(sp->hook), msg, sp->creator, 0);
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ struct ngpppoestat {
|
|||||||
* and begin negotiation.
|
* and begin negotiation.
|
||||||
*/
|
*/
|
||||||
struct ngpppoe_init_data {
|
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 */
|
u_int16_t data_len; /* Length of the service name */
|
||||||
char data[0]; /* init data goes here */
|
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).
|
* to whoever requested the connection. (close may use this too).
|
||||||
*/
|
*/
|
||||||
struct ngpppoe_sts {
|
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 */
|
/* Keep this in sync with the above structure definition */
|
||||||
|
@ -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;
|
struct sockaddr_ng *const sap = (struct sockaddr_ng *) addr;
|
||||||
int len, error;
|
int len, error;
|
||||||
hook_p hook = NULL;
|
hook_p hook = NULL;
|
||||||
char hookname[NG_HOOKLEN + 1];
|
char hookname[NG_HOOKSIZ];
|
||||||
|
|
||||||
if ((pcbp == NULL) || (control != NULL)) {
|
if ((pcbp == NULL) || (control != NULL)) {
|
||||||
error = EINVAL;
|
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);
|
hook = LIST_FIRST(&pcbp->sockdata->node->nd_hooks);
|
||||||
} else {
|
} else {
|
||||||
if (len > NG_HOOKLEN) {
|
if (len >= NG_HOOKSIZ) {
|
||||||
error = EINVAL;
|
error = EINVAL;
|
||||||
goto release;
|
goto release;
|
||||||
}
|
}
|
||||||
@ -698,7 +698,7 @@ ng_bind(struct sockaddr *nam, struct ngpcb *pcbp)
|
|||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
}
|
}
|
||||||
if ((sap->sg_len < 4)
|
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[0] == '\0')
|
||||||
|| (sap->sg_data[sap->sg_len - 3] != '\0')) {
|
|| (sap->sg_data[sap->sg_len - 3] != '\0')) {
|
||||||
TRAP_ERROR;
|
TRAP_ERROR;
|
||||||
@ -863,7 +863,7 @@ ngs_rcvdata(hook_p hook, item_p item)
|
|||||||
struct ngpcb *const pcbp = priv->datasock;
|
struct ngpcb *const pcbp = priv->datasock;
|
||||||
struct socket *so;
|
struct socket *so;
|
||||||
struct sockaddr_ng *addr;
|
struct sockaddr_ng *addr;
|
||||||
char *addrbuf[NG_HOOKLEN + 1 + 4];
|
char *addrbuf[NG_HOOKSIZ + 4];
|
||||||
int addrlen;
|
int addrlen;
|
||||||
struct mbuf *m;
|
struct mbuf *m;
|
||||||
|
|
||||||
@ -877,7 +877,7 @@ ngs_rcvdata(hook_p hook, item_p item)
|
|||||||
so = pcbp->ng_socket;
|
so = pcbp->ng_socket;
|
||||||
|
|
||||||
/* Get the return address into a sockaddr. */
|
/* 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 = (struct sockaddr_ng *) addrbuf;
|
||||||
addr->sg_len = addrlen + 3;
|
addr->sg_len = addrlen + 3;
|
||||||
addr->sg_family = AF_NETGRAPH;
|
addr->sg_family = AF_NETGRAPH;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user