Replace all uses of the old netgraph constants NG_*LEN by the new

constants NG_*SIZ that include the trailing NUL byte. This change
is mostly mechanical except for the replacement of a couple of snprintf()
and sprintf() calls with strlcpy.
This commit is contained in:
Hartmut Brandt 2003-11-15 15:26:35 +00:00
parent 53b2520d01
commit 89624a3490
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=122758
16 changed files with 135 additions and 135 deletions

View file

@ -44,7 +44,7 @@ IMPORTS
FROM BEGEMOT-MIB;
begemotNg MODULE-IDENTITY
LAST-UPDATED "200201310000Z"
LAST-UPDATED "200311140000Z"
ORGANIZATION "Fraunhofer FOKUS, CATS"
CONTACT-INFO
" Hartmut Brandt
@ -66,32 +66,32 @@ begemotNgObjects OBJECT IDENTIFIER ::= { begemotNg 1 }
-- --------------------------------------------------------------------------
NgTypeName ::= TEXTUAL-CONVENTION
DISPLAY-HINT "15a"
DISPLAY-HINT "31a"
STATUS current
DESCRIPTION
"Name of a netgraph type."
SYNTAX OCTET STRING (SIZE(1..15))
SYNTAX OCTET STRING (SIZE(1..31))
NgNodeName ::= TEXTUAL-CONVENTION
DISPLAY-HINT "15a"
DISPLAY-HINT "31a"
STATUS current
DESCRIPTION
"Name of a netgraph node."
SYNTAX OCTET STRING (SIZE(1..15))
SYNTAX OCTET STRING (SIZE(1..31))
NgNodeNameOrEmpty ::= TEXTUAL-CONVENTION
DISPLAY-HINT "15a"
DISPLAY-HINT "31a"
STATUS current
DESCRIPTION
"Name of a netgraph node."
SYNTAX OCTET STRING (SIZE(0..15))
SYNTAX OCTET STRING (SIZE(0..31))
NgHookName ::= TEXTUAL-CONVENTION
DISPLAY-HINT "15a"
DISPLAY-HINT "31a"
STATUS current
DESCRIPTION
"Name of a netgraph hook."
SYNTAX OCTET STRING (SIZE(1..15))
SYNTAX OCTET STRING (SIZE(1..31))
NgNodeId ::= TEXTUAL-CONVENTION
DISPLAY-HINT "x"

View file

@ -29,7 +29,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd October 7, 2003
.Dd November 14, 2003
.Dt snmp_netgraph 3
.Os
.Sh NAME
@ -289,8 +289,8 @@ retrieves the name of the node with id
and writes it to the buffer pointed to by
.Fa name .
This buffer should be at least
.Li NG_NODELEN
+ 1 long. The function returns the node id or 0 if the
.Li NG_NODESIZ
bytes long. The function returns the node id or 0 if the
node is not found
.Pp
The function
@ -300,8 +300,8 @@ retrieves the name of the node with id
and writes it to the buffer pointed to by
.Fa type .
This buffer should be at least
.Li NG_TYPELEN
+ 1 long. The function returns the node id or 0 if the
.Li NG_TYPESIZ
bytes long. The function returns the node id or 0 if the
node is not found.
.Pp
The function
@ -313,8 +313,8 @@ on the node with
to the buffer pointed to by
.Fa peer_hook .
The buffer should be at least
.Li NG_HOOKLEN
+ 1 long. The function returns 0 if the node and the hook is found, -1
.Li NG_HOOKSIZ
bytes long. The function returns 0 if the node and the hook is found, -1
otherwise. The function skips intermediate tee nodes (see
.Xr ng_tee 4 ).
.Pp

View file

@ -79,7 +79,7 @@ static struct clockinfo clockinfo;
struct csock_buf {
STAILQ_ENTRY(csock_buf) link;
struct ng_mesg *mesg;
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
};
static STAILQ_HEAD(, csock_buf) csock_bufs =
STAILQ_HEAD_INITIALIZER(csock_bufs);
@ -103,7 +103,7 @@ static SLIST_HEAD(, msgreg) msgreg_list =
* Data messages are dispatched by hook names.
*/
struct datareg {
char hook[NG_HOOKLEN + 1];
char hook[NG_HOOKSIZ];
ng_hook_f *func;
void *arg;
const struct lmodule *mod;
@ -124,7 +124,7 @@ static u_int32_t stats[LEAF_begemotNgTooLargeDatas+1];
/* netgraph type list */
struct ngtype {
char name[NG_TYPELEN + 1];
char name[NG_TYPESIZ];
struct asn_oid index;
TAILQ_ENTRY(ngtype) link;
};
@ -307,7 +307,7 @@ static void
csock_input(int fd __unused, void *udata __unused)
{
struct ng_mesg *mesg;
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
if ((mesg = csock_read(path)) == NULL)
return;
@ -328,7 +328,7 @@ int
ng_output_node(const char *node, u_int cookie, u_int opcode,
const void *arg, size_t arglen)
{
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
sprintf(path, "%s:", node);
return (ng_output(path, cookie, opcode, arg, arglen));
@ -337,7 +337,7 @@ int
ng_output_id(ng_ID_t node, u_int cookie, u_int opcode,
const void *arg, size_t arglen)
{
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
sprintf(path, "[%x]:", node);
return (ng_output(path, cookie, opcode, arg, arglen));
@ -355,7 +355,7 @@ ng_dialog(const char *path, u_int cookie, u_int opcode,
{
int token, err;
struct ng_mesg *mesg;
char rpath[NG_PATHLEN + 1];
char rpath[NG_PATHSIZ];
struct csock_buf *b;
struct timeval end, tv;
@ -420,7 +420,7 @@ struct ng_mesg *
ng_dialog_node(const char *node, u_int cookie, u_int opcode,
const void *arg, size_t arglen)
{
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
sprintf(path, "%s:", node);
return (ng_dialog(path, cookie, opcode, arg, arglen));
@ -429,7 +429,7 @@ struct ng_mesg *
ng_dialog_id(ng_ID_t id, u_int cookie, u_int opcode,
const void *arg, size_t arglen)
{
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
sprintf(path, "[%x]:", id);
return (ng_dialog(path, cookie, opcode, arg, arglen));
@ -453,7 +453,7 @@ dsock_input(int fd __unused, void *udata __unused)
{
u_char *resbuf, embuf[100];
ssize_t len;
char hook[NG_HOOKLEN + 1];
char hook[NG_HOOKSIZ];
struct datareg *d, *d1;
if ((resbuf = malloc(resbufsiz + 1)) == NULL) {
@ -530,9 +530,9 @@ ng_init(struct lmodule *mod, int argc, char *argv[])
return (ENOMEM);
strcpy(snmp_nodename, NODENAME);
} else {
if ((snmp_nodename = malloc(NG_NODELEN + 1)) == NULL)
if ((snmp_nodename = malloc(NG_NODESIZ)) == NULL)
return (ENOMEM);
snprintf(snmp_nodename, NG_NODELEN + 1, "%s", argv[0]);
strlcpy(snmp_nodename, argv[0], NG_NODESIZ);
}
/* fetch clockinfo (for the number of microseconds per tick) */
@ -610,9 +610,9 @@ ng_connect_node(const char *node, const char *ourhook, const char *peerhook)
{
struct ngm_connect conn;
snprintf(conn.path, NG_PATHLEN + 1, "%s:", node);
snprintf(conn.ourhook, NG_HOOKLEN + 1, ourhook);
snprintf(conn.peerhook, NG_HOOKLEN + 1, peerhook);
snprintf(conn.path, NG_PATHSIZ, "%s:", node);
strlcpy(conn.ourhook, ourhook, NG_HOOKSIZ);
strlcpy(conn.peerhook, peerhook, NG_HOOKSIZ);
return (NgSendMsg(csock, ".:",
NGM_GENERIC_COOKIE, NGM_CONNECT, &conn, sizeof(conn)));
}
@ -621,9 +621,9 @@ ng_connect_id(ng_ID_t id, const char *ourhook, const char *peerhook)
{
struct ngm_connect conn;
snprintf(conn.path, NG_PATHLEN + 1, "[%x]:", id);
snprintf(conn.ourhook, NG_HOOKLEN + 1, ourhook);
snprintf(conn.peerhook, NG_HOOKLEN + 1, peerhook);
snprintf(conn.path, NG_PATHSIZ, "[%x]:", id);
strlcpy(conn.ourhook, ourhook, NG_HOOKSIZ);
strlcpy(conn.peerhook, peerhook, NG_HOOKSIZ);
return (NgSendMsg(csock, ".:",
NGM_GENERIC_COOKIE, NGM_CONNECT, &conn, sizeof(conn)));
}
@ -633,13 +633,13 @@ ng_connect2_id(ng_ID_t id, ng_ID_t peer, const char *ourhook,
const char *peerhook)
{
struct ngm_connect conn;
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
snprintf(path, NG_PATHLEN + 1, "[%x]:", id);
snprintf(path, NG_PATHSIZ, "[%x]:", id);
snprintf(conn.path, NG_PATHLEN + 1, "[%x]:", peer);
snprintf(conn.ourhook, NG_HOOKLEN + 1, ourhook);
snprintf(conn.peerhook, NG_HOOKLEN + 1, peerhook);
snprintf(conn.path, NG_PATHSIZ, "[%x]:", peer);
strlcpy(conn.ourhook, ourhook, NG_HOOKSIZ);
strlcpy(conn.peerhook, peerhook, NG_HOOKSIZ);
return (NgSendMsg(csock, path,
NGM_GENERIC_COOKIE, NGM_CONNECT, &conn, sizeof(conn)));
}
@ -649,17 +649,17 @@ ng_connect2_tee_id(ng_ID_t id, ng_ID_t peer, const char *ourhook,
const char *peerhook)
{
struct ngm_connect conn;
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
ng_ID_t tee;
if ((tee = ng_mkpeer_id(id, NULL, "tee", ourhook, "left")) == 0)
return (-1);
snprintf(path, NG_PATHLEN + 1, "[%x]:", tee);
snprintf(path, NG_PATHSIZ, "[%x]:", tee);
snprintf(conn.path, NG_PATHLEN + 1, "[%x]:", peer);
snprintf(conn.ourhook, NG_HOOKLEN + 1, "right");
snprintf(conn.peerhook, NG_HOOKLEN + 1, peerhook);
snprintf(conn.path, NG_PATHSIZ, "[%x]:", peer);
strlcpy(conn.ourhook, "right", NG_HOOKSIZ);
strlcpy(conn.peerhook, peerhook, NG_HOOKSIZ);
return (NgSendMsg(csock, path,
NGM_GENERIC_COOKIE, NGM_CONNECT, &conn, sizeof(conn)));
}
@ -730,13 +730,13 @@ ng_ID_t
ng_mkpeer_id(ng_ID_t id, const char *nodename, const char *type,
const char *hook, const char *peerhook)
{
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
struct ngm_mkpeer mkpeer;
struct ngm_name name;
strcpy(mkpeer.type, type);
strcpy(mkpeer.ourhook, hook);
strcpy(mkpeer.peerhook, peerhook);
strlcpy(mkpeer.type, type, NG_TYPESIZ);
strlcpy(mkpeer.ourhook, hook, NG_HOOKSIZ);
strlcpy(mkpeer.peerhook, peerhook, NG_HOOKSIZ);
sprintf(path, "[%x]:", id);
if (NgSendMsg(csock, path, NGM_GENERIC_COOKIE, NGM_MKPEER,
@ -762,9 +762,9 @@ ng_mkpeer_id(ng_ID_t id, const char *nodename, const char *type,
int
ng_shutdown_id(ng_ID_t id)
{
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
sprintf(path, "[%x]:", id);
snprintf(path, NG_PATHSIZ, "[%x]:", id);
return (NgSendMsg(csock, path, NGM_GENERIC_COOKIE,
NGM_SHUTDOWN, NULL, 0));
}
@ -777,7 +777,7 @@ ng_rmhook(const char *ourhook)
{
struct ngm_rmhook rmhook;
snprintf(rmhook.ourhook, NG_HOOKLEN + 1, "%s", ourhook);
strlcpy(rmhook.ourhook, ourhook, NG_HOOKSIZ);
return (NgSendMsg(csock, ".:",
NGM_GENERIC_COOKIE, NGM_RMHOOK, &rmhook, sizeof(rmhook)));
}
@ -789,10 +789,10 @@ int
ng_rmhook_id(ng_ID_t id, const char *hook)
{
struct ngm_rmhook rmhook;
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
snprintf(rmhook.ourhook, NG_HOOKLEN + 1, "%s", hook);
sprintf(path, "[%x]:", id);
strlcpy(rmhook.ourhook, hook, NG_HOOKSIZ);
snprintf(path, NG_PATHSIZ, "[%x]:", id);
return (NgSendMsg(csock, path,
NGM_GENERIC_COOKIE, NGM_RMHOOK, &rmhook, sizeof(rmhook)));
}
@ -1243,7 +1243,7 @@ op_ng_type(struct snmp_context *ctx, struct snmp_value *value,
case SNMP_OP_SET:
if (index_decode(&value->var, sub, iidx, &name, &namelen))
return (SNMP_ERR_NO_CREATION);
if (namelen == 0 || namelen > NG_TYPELEN) {
if (namelen == 0 || namelen >= NG_TYPESIZ) {
free(name);
return (SNMP_ERR_NO_CREATION);
}

View file

@ -497,7 +497,7 @@ nglogx(const char *fmt, ...)
int
main(int argc, char *argv[])
{
char hostname[MAXHOSTNAMELEN], *exec, rhook[NG_HOOKLEN + 1];
char hostname[MAXHOSTNAMELEN], *exec, rhook[NG_HOOKSIZ];
unsigned char response[1024];
const char *label, *prog, *provider, *acname;
struct ngm_connect ngc;

View file

@ -150,8 +150,8 @@
#
# /* 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;
# };
#

View file

@ -232,7 +232,7 @@ all traffic types however):
Initialize a VCC for sending and receiving. The argument is a structure:
.Bd -literal
struct ng_atm_cpcs_init {
char name[NG_HOOKLEN + 1];
char name[NG_HOOKSIZ];
uint32_t flags; /* flags. (if_natmio.h) */
uint16_t vci; /* VCI to open */
uint16_t vpi; /* VPI to open */
@ -276,7 +276,7 @@ type of traffic.
Stop sending and receiving on the indicated hook. The argument is a
.Bd -literal
struct ng_atm_cpcs_term {
char name[NG_HOOKLEN + 1];
char name[NG_HOOKSIZ];
};
.Ed
.El

View file

@ -82,9 +82,9 @@ This command sets the filter program that will be applied to incoming
data on a hook. The following structure must be supplied as an argument:
.Bd -literal -offset 4n
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[0]; /* bpf program */
};

View file

@ -100,7 +100,7 @@ are specified in a structure of type
.Vt "struct ng_etffilter" :
.Bd -literal -offset 4n
struct ng_etffilter {
char matchhook[NG_HOOKLEN + 1]; /* hook name */
char matchhook[NG_HOOKSIZ]; /* hook name */
u_int16_t ethertype; /* catch these */
};
.Ed

View file

@ -135,7 +135,7 @@ structure shown below.
The three commands above use a common data structure:
.Bd -literal -offset 4n
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; /* service name length */
char data[0]; /* init data goes here */
};
@ -171,7 +171,7 @@ above messages, and reports the Access Concentrator Name.
The four commands above use a common data structure:
.Bd -literal -offset 4n
struct ngpppoe_sts {
char hook[NG_HOOKLEN + 1]; /* hook associated with event session */
char hook[NG_HOOKSIZ]; /* hook associated with event session */
};
.Ed
.Sh SHUTDOWN
@ -257,7 +257,7 @@ setup(char *ethername, char *service, char *sessname,
} message;
/********tracking our little graph ********/
char path[100];
char source_ID[NG_NODELEN + 1];
char source_ID[NG_NODESIZ];
char pppoe_node_name[100];
int k;

View file

@ -94,7 +94,7 @@ int
main(int argc, char *argv[])
{
FILE *firmware_file = NULL;
char buffer[80], path[NG_PATHLEN + 1],
char buffer[80], path[NG_PATHSIZ],
*firmware_filename = NULL;
u_int8_t *firmware = NULL;
int firmware_size, opt, cs, ds;

View file

@ -173,7 +173,7 @@ open_device(char const *device, speed_t speed, char const *name)
struct termios t;
struct nodeinfo ni;
struct ngm_name n;
char p[NG_NODELEN + 1];
char p[NG_NODESIZ];
/* Open terminal device and setup H4 line discipline */
fd = open(device, O_RDWR|O_NOCTTY);

View file

@ -44,7 +44,7 @@ IMPORTS
FROM BEGEMOT-MIB;
begemotNg MODULE-IDENTITY
LAST-UPDATED "200201310000Z"
LAST-UPDATED "200311140000Z"
ORGANIZATION "Fraunhofer FOKUS, CATS"
CONTACT-INFO
" Hartmut Brandt
@ -66,32 +66,32 @@ begemotNgObjects OBJECT IDENTIFIER ::= { begemotNg 1 }
-- --------------------------------------------------------------------------
NgTypeName ::= TEXTUAL-CONVENTION
DISPLAY-HINT "15a"
DISPLAY-HINT "31a"
STATUS current
DESCRIPTION
"Name of a netgraph type."
SYNTAX OCTET STRING (SIZE(1..15))
SYNTAX OCTET STRING (SIZE(1..31))
NgNodeName ::= TEXTUAL-CONVENTION
DISPLAY-HINT "15a"
DISPLAY-HINT "31a"
STATUS current
DESCRIPTION
"Name of a netgraph node."
SYNTAX OCTET STRING (SIZE(1..15))
SYNTAX OCTET STRING (SIZE(1..31))
NgNodeNameOrEmpty ::= TEXTUAL-CONVENTION
DISPLAY-HINT "15a"
DISPLAY-HINT "31a"
STATUS current
DESCRIPTION
"Name of a netgraph node."
SYNTAX OCTET STRING (SIZE(0..15))
SYNTAX OCTET STRING (SIZE(0..31))
NgHookName ::= TEXTUAL-CONVENTION
DISPLAY-HINT "15a"
DISPLAY-HINT "31a"
STATUS current
DESCRIPTION
"Name of a netgraph hook."
SYNTAX OCTET STRING (SIZE(1..15))
SYNTAX OCTET STRING (SIZE(1..31))
NgNodeId ::= TEXTUAL-CONVENTION
DISPLAY-HINT "x"

View file

@ -29,7 +29,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd October 7, 2003
.Dd November 14, 2003
.Dt snmp_netgraph 3
.Os
.Sh NAME
@ -289,8 +289,8 @@ retrieves the name of the node with id
and writes it to the buffer pointed to by
.Fa name .
This buffer should be at least
.Li NG_NODELEN
+ 1 long. The function returns the node id or 0 if the
.Li NG_NODESIZ
bytes long. The function returns the node id or 0 if the
node is not found
.Pp
The function
@ -300,8 +300,8 @@ retrieves the name of the node with id
and writes it to the buffer pointed to by
.Fa type .
This buffer should be at least
.Li NG_TYPELEN
+ 1 long. The function returns the node id or 0 if the
.Li NG_TYPESIZ
bytes long. The function returns the node id or 0 if the
node is not found.
.Pp
The function
@ -313,8 +313,8 @@ on the node with
to the buffer pointed to by
.Fa peer_hook .
The buffer should be at least
.Li NG_HOOKLEN
+ 1 long. The function returns 0 if the node and the hook is found, -1
.Li NG_HOOKSIZ
bytes long. The function returns 0 if the node and the hook is found, -1
otherwise. The function skips intermediate tee nodes (see
.Xr ng_tee 4 ).
.Pp

View file

@ -79,7 +79,7 @@ static struct clockinfo clockinfo;
struct csock_buf {
STAILQ_ENTRY(csock_buf) link;
struct ng_mesg *mesg;
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
};
static STAILQ_HEAD(, csock_buf) csock_bufs =
STAILQ_HEAD_INITIALIZER(csock_bufs);
@ -103,7 +103,7 @@ static SLIST_HEAD(, msgreg) msgreg_list =
* Data messages are dispatched by hook names.
*/
struct datareg {
char hook[NG_HOOKLEN + 1];
char hook[NG_HOOKSIZ];
ng_hook_f *func;
void *arg;
const struct lmodule *mod;
@ -124,7 +124,7 @@ static u_int32_t stats[LEAF_begemotNgTooLargeDatas+1];
/* netgraph type list */
struct ngtype {
char name[NG_TYPELEN + 1];
char name[NG_TYPESIZ];
struct asn_oid index;
TAILQ_ENTRY(ngtype) link;
};
@ -307,7 +307,7 @@ static void
csock_input(int fd __unused, void *udata __unused)
{
struct ng_mesg *mesg;
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
if ((mesg = csock_read(path)) == NULL)
return;
@ -328,7 +328,7 @@ int
ng_output_node(const char *node, u_int cookie, u_int opcode,
const void *arg, size_t arglen)
{
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
sprintf(path, "%s:", node);
return (ng_output(path, cookie, opcode, arg, arglen));
@ -337,7 +337,7 @@ int
ng_output_id(ng_ID_t node, u_int cookie, u_int opcode,
const void *arg, size_t arglen)
{
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
sprintf(path, "[%x]:", node);
return (ng_output(path, cookie, opcode, arg, arglen));
@ -355,7 +355,7 @@ ng_dialog(const char *path, u_int cookie, u_int opcode,
{
int token, err;
struct ng_mesg *mesg;
char rpath[NG_PATHLEN + 1];
char rpath[NG_PATHSIZ];
struct csock_buf *b;
struct timeval end, tv;
@ -420,7 +420,7 @@ struct ng_mesg *
ng_dialog_node(const char *node, u_int cookie, u_int opcode,
const void *arg, size_t arglen)
{
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
sprintf(path, "%s:", node);
return (ng_dialog(path, cookie, opcode, arg, arglen));
@ -429,7 +429,7 @@ struct ng_mesg *
ng_dialog_id(ng_ID_t id, u_int cookie, u_int opcode,
const void *arg, size_t arglen)
{
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
sprintf(path, "[%x]:", id);
return (ng_dialog(path, cookie, opcode, arg, arglen));
@ -453,7 +453,7 @@ dsock_input(int fd __unused, void *udata __unused)
{
u_char *resbuf, embuf[100];
ssize_t len;
char hook[NG_HOOKLEN + 1];
char hook[NG_HOOKSIZ];
struct datareg *d, *d1;
if ((resbuf = malloc(resbufsiz + 1)) == NULL) {
@ -530,9 +530,9 @@ ng_init(struct lmodule *mod, int argc, char *argv[])
return (ENOMEM);
strcpy(snmp_nodename, NODENAME);
} else {
if ((snmp_nodename = malloc(NG_NODELEN + 1)) == NULL)
if ((snmp_nodename = malloc(NG_NODESIZ)) == NULL)
return (ENOMEM);
snprintf(snmp_nodename, NG_NODELEN + 1, "%s", argv[0]);
strlcpy(snmp_nodename, argv[0], NG_NODESIZ);
}
/* fetch clockinfo (for the number of microseconds per tick) */
@ -610,9 +610,9 @@ ng_connect_node(const char *node, const char *ourhook, const char *peerhook)
{
struct ngm_connect conn;
snprintf(conn.path, NG_PATHLEN + 1, "%s:", node);
snprintf(conn.ourhook, NG_HOOKLEN + 1, ourhook);
snprintf(conn.peerhook, NG_HOOKLEN + 1, peerhook);
snprintf(conn.path, NG_PATHSIZ, "%s:", node);
strlcpy(conn.ourhook, ourhook, NG_HOOKSIZ);
strlcpy(conn.peerhook, peerhook, NG_HOOKSIZ);
return (NgSendMsg(csock, ".:",
NGM_GENERIC_COOKIE, NGM_CONNECT, &conn, sizeof(conn)));
}
@ -621,9 +621,9 @@ ng_connect_id(ng_ID_t id, const char *ourhook, const char *peerhook)
{
struct ngm_connect conn;
snprintf(conn.path, NG_PATHLEN + 1, "[%x]:", id);
snprintf(conn.ourhook, NG_HOOKLEN + 1, ourhook);
snprintf(conn.peerhook, NG_HOOKLEN + 1, peerhook);
snprintf(conn.path, NG_PATHSIZ, "[%x]:", id);
strlcpy(conn.ourhook, ourhook, NG_HOOKSIZ);
strlcpy(conn.peerhook, peerhook, NG_HOOKSIZ);
return (NgSendMsg(csock, ".:",
NGM_GENERIC_COOKIE, NGM_CONNECT, &conn, sizeof(conn)));
}
@ -633,13 +633,13 @@ ng_connect2_id(ng_ID_t id, ng_ID_t peer, const char *ourhook,
const char *peerhook)
{
struct ngm_connect conn;
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
snprintf(path, NG_PATHLEN + 1, "[%x]:", id);
snprintf(path, NG_PATHSIZ, "[%x]:", id);
snprintf(conn.path, NG_PATHLEN + 1, "[%x]:", peer);
snprintf(conn.ourhook, NG_HOOKLEN + 1, ourhook);
snprintf(conn.peerhook, NG_HOOKLEN + 1, peerhook);
snprintf(conn.path, NG_PATHSIZ, "[%x]:", peer);
strlcpy(conn.ourhook, ourhook, NG_HOOKSIZ);
strlcpy(conn.peerhook, peerhook, NG_HOOKSIZ);
return (NgSendMsg(csock, path,
NGM_GENERIC_COOKIE, NGM_CONNECT, &conn, sizeof(conn)));
}
@ -649,17 +649,17 @@ ng_connect2_tee_id(ng_ID_t id, ng_ID_t peer, const char *ourhook,
const char *peerhook)
{
struct ngm_connect conn;
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
ng_ID_t tee;
if ((tee = ng_mkpeer_id(id, NULL, "tee", ourhook, "left")) == 0)
return (-1);
snprintf(path, NG_PATHLEN + 1, "[%x]:", tee);
snprintf(path, NG_PATHSIZ, "[%x]:", tee);
snprintf(conn.path, NG_PATHLEN + 1, "[%x]:", peer);
snprintf(conn.ourhook, NG_HOOKLEN + 1, "right");
snprintf(conn.peerhook, NG_HOOKLEN + 1, peerhook);
snprintf(conn.path, NG_PATHSIZ, "[%x]:", peer);
strlcpy(conn.ourhook, "right", NG_HOOKSIZ);
strlcpy(conn.peerhook, peerhook, NG_HOOKSIZ);
return (NgSendMsg(csock, path,
NGM_GENERIC_COOKIE, NGM_CONNECT, &conn, sizeof(conn)));
}
@ -730,13 +730,13 @@ ng_ID_t
ng_mkpeer_id(ng_ID_t id, const char *nodename, const char *type,
const char *hook, const char *peerhook)
{
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
struct ngm_mkpeer mkpeer;
struct ngm_name name;
strcpy(mkpeer.type, type);
strcpy(mkpeer.ourhook, hook);
strcpy(mkpeer.peerhook, peerhook);
strlcpy(mkpeer.type, type, NG_TYPESIZ);
strlcpy(mkpeer.ourhook, hook, NG_HOOKSIZ);
strlcpy(mkpeer.peerhook, peerhook, NG_HOOKSIZ);
sprintf(path, "[%x]:", id);
if (NgSendMsg(csock, path, NGM_GENERIC_COOKIE, NGM_MKPEER,
@ -762,9 +762,9 @@ ng_mkpeer_id(ng_ID_t id, const char *nodename, const char *type,
int
ng_shutdown_id(ng_ID_t id)
{
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
sprintf(path, "[%x]:", id);
snprintf(path, NG_PATHSIZ, "[%x]:", id);
return (NgSendMsg(csock, path, NGM_GENERIC_COOKIE,
NGM_SHUTDOWN, NULL, 0));
}
@ -777,7 +777,7 @@ ng_rmhook(const char *ourhook)
{
struct ngm_rmhook rmhook;
snprintf(rmhook.ourhook, NG_HOOKLEN + 1, "%s", ourhook);
strlcpy(rmhook.ourhook, ourhook, NG_HOOKSIZ);
return (NgSendMsg(csock, ".:",
NGM_GENERIC_COOKIE, NGM_RMHOOK, &rmhook, sizeof(rmhook)));
}
@ -789,10 +789,10 @@ int
ng_rmhook_id(ng_ID_t id, const char *hook)
{
struct ngm_rmhook rmhook;
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
snprintf(rmhook.ourhook, NG_HOOKLEN + 1, "%s", hook);
sprintf(path, "[%x]:", id);
strlcpy(rmhook.ourhook, hook, NG_HOOKSIZ);
snprintf(path, NG_PATHSIZ, "[%x]:", id);
return (NgSendMsg(csock, path,
NGM_GENERIC_COOKIE, NGM_RMHOOK, &rmhook, sizeof(rmhook)));
}
@ -1243,7 +1243,7 @@ op_ng_type(struct snmp_context *ctx, struct snmp_value *value,
case SNMP_OP_SET:
if (index_decode(&value->var, sub, iidx, &name, &namelen))
return (SNMP_ERR_NO_CREATION);
if (namelen == 0 || namelen > NG_TYPELEN) {
if (namelen == 0 || namelen >= NG_TYPESIZ) {
free(name);
return (SNMP_ERR_NO_CREATION);
}

View file

@ -91,7 +91,7 @@
struct ngdevice {
struct device dev; /* What struct physical knows about */
int cs; /* Control socket */
char hook[NG_HOOKLEN + 1]; /* Our socket node hook */
char hook[NG_HOOKSIZ]; /* Our socket node hook */
};
#define device2ng(d) ((d)->type == NG_DEVICE ? (struct ngdevice *)d : NULL)
@ -107,7 +107,7 @@ ng_DeviceSize(void)
static int
ng_MessageOut(struct ngdevice *dev, struct physical *p, const char *data)
{
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
int len, pos, dpos;
char *fmt;
@ -168,7 +168,7 @@ ng_MessageIn(struct physical *p, char *buf, size_t sz)
char msgbuf[sizeof(struct ng_mesg) * 2 + NG_MSGBUFSZ];
struct ngdevice *dev = device2ng(p->handler);
struct ng_mesg *rep = (struct ng_mesg *)msgbuf;
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
int len;
#ifdef BROKEN_SELECT
@ -232,7 +232,7 @@ ng_Write(struct physical *p, const void *v, size_t n)
static ssize_t
ng_Read(struct physical *p, void *v, size_t n)
{
char hook[NG_HOOKLEN + 1];
char hook[NG_HOOKSIZ];
log_Printf(LogDEBUG, "ng_Read\n");
switch (p->dl->state) {
@ -462,11 +462,11 @@ ng_Create(struct physical *p)
struct ngm_mkpeer mkp;
struct ngm_connect ngc;
const char *devp, *endp;
char lasthook[NG_HOOKLEN + 1];
char hook[NG_HOOKLEN + 1];
char nodetype[NG_TYPELEN + NG_NODELEN + 2];
char modname[NG_TYPELEN + 4];
char path[NG_PATHLEN + 1];
char lasthook[NG_HOOKSIZ];
char hook[NG_HOOKSIZ];
char nodetype[NG_TYPESIZ + NG_NODESIZ];
char modname[NG_TYPESIZ + 3];
char path[NG_PATHSIZ];
char *nodename;
int len, sz, done, f;

View file

@ -227,7 +227,7 @@ static void
tty_SetAsyncParams(struct physical *p, u_int32_t mymap, u_int32_t hismap)
{
struct ttydevice *dev = device2tty(p->handler);
char asyncpath[NG_PATHLEN + 1];
char asyncpath[NG_PATHSIZ];
struct ng_async_cfg cfg;
if (isngtty(dev)) {
@ -256,7 +256,7 @@ LoadLineDiscipline(struct physical *p)
u_char rbuf[sizeof(struct ng_mesg) + sizeof(struct nodeinfo)];
struct ng_mesg *reply;
struct nodeinfo *info;
char ttypath[NG_NODELEN + 1];
char ttypath[NG_NODESIZ];
struct ngm_mkpeer ngm;
struct ngm_connect ngc;
int ldisc, cs, ds, hot, speed;