netgraph-remove-xLEN.patch

nant, 06/03/2007 04:04 PM

Download (19.6 KB)

View differences:

sys/dev/netif/ar/if_ar.c
123 123
	int	running;	/* something is attached so we are running */
124 124
	int	dcd;		/* do we have dcd? */
125 125
	/* ---netgraph bits --- */
126
	char		nodename[NG_NODELEN + 1]; /* store our node name */
126
	char		nodename[NG_NODESIZ]; /* store our node name */
127 127
	int		datahooks;	/* number of data hooks attached */
128 128
	node_p		node;		/* netgraph node */
129 129
	hook_p		hook;		/* data hook */
sys/dev/netif/mn/if_mn.c
259 259
	char		name[8];
260 260
	u_int32_t	falc_irq, falc_state, framer_state;
261 261
	struct schan *ch[M32_CHAN];
262
	char	nodename[NG_NODELEN + 1];
262
	char	nodename[NG_NODESIZ];
263 263
	node_p	node;
264 264

  
265 265
	u_long		cnt_fec;
sys/dev/netif/sr/if_sr.c
139 139
	int	running;	/* something is attached so we are running */
140 140
	int	dcd;		/* do we have dcd? */
141 141
	/* ---netgraph bits --- */
142
	char		nodename[NG_NODELEN + 1]; /* store our node name */
142
	char		nodename[NG_NODESIZ]; /* store our node name */
143 143
	int		datahooks;	/* number of data hooks attached */
144 144
	node_p		node;		/* netgraph node */
145 145
	hook_p		hook;		/* data hook */
......
2852 2852
			    (*resp)->header.token = msg->header.token;
2853 2853
			    (*resp)->header.typecookie = NG_SR_COOKIE;
2854 2854
			    (*resp)->header.cmd = msg->header.cmd;
2855
			    strncpy((*resp)->header.cmdstr, "status",
2856
					NG_CMDSTRLEN);
2855
			    strlcpy((*resp)->header.cmdstr, "status",
2856
					NG_CMDSTRSIZ);
2857 2857
			}
2858 2858
			break;
2859 2859
	    	    default:
sys/netgraph/bpf/ng_bpf.h
50 50

  
51 51
/* Program structure for one hook */
52 52
struct ng_bpf_hookprog {
53
	char		thisHook[NG_HOOKLEN+1];		/* name of hook */
54
	char		ifMatch[NG_HOOKLEN+1];		/* match dest hook */
55
	char		ifNotMatch[NG_HOOKLEN+1];	/* !match dest hook */
53
	char		thisHook[NG_HOOKSIZ];		/* name of hook */
54
	char		ifMatch[NG_HOOKSIZ];		/* match dest hook */
55
	char		ifNotMatch[NG_HOOKSIZ];		/* !match dest hook */
56 56
	int32_t		bpf_prog_len;			/* #isns in program */
57 57
	struct bpf_insn	bpf_prog[__ARRAY_ZERO];		/* bpf program */
58 58
};
......
95 95
enum {
96 96
	NGM_BPF_SET_PROGRAM = 1,	/* supply a struct ng_bpf_hookprog */
97 97
	NGM_BPF_GET_PROGRAM,		/* returns a struct ng_bpf_hookprog */
98
	NGM_BPF_GET_STATS,		/* supply name as char[NG_HOOKLEN+1] */
99
	NGM_BPF_CLR_STATS,		/* supply name as char[NG_HOOKLEN+1] */
100
	NGM_BPF_GETCLR_STATS,		/* supply name as char[NG_HOOKLEN+1] */
98
	NGM_BPF_GET_STATS,		/* supply name as char[NG_HOOKSIZ] */
99
	NGM_BPF_CLR_STATS,		/* supply name as char[NG_HOOKSIZ] */
100
	NGM_BPF_GETCLR_STATS,		/* supply name as char[NG_HOOKSIZ] */
101 101
};
102 102

  
103 103
#endif /* _NETGRAPH_BPF_H_ */
sys/netgraph/bridge/ng_bridge.c
1012 1012
static const char *
1013 1013
ng_bridge_nodename(node_p node)
1014 1014
{
1015
	static char name[NG_NODELEN+1];
1015
	static char name[NG_NODESIZ];
1016 1016

  
1017 1017
	if (node->name != NULL)
1018 1018
		ksnprintf(name, sizeof(name), "%s", node->name);
sys/netgraph/etf/ng_etf.h
73 73

  
74 74
/* This structure is returned by the NGM_ETF_GET_STATUS command */
75 75
struct ng_etffilter {
76
	char		matchhook[NG_HOOKLEN + 1]; /* hook name */
76
	char		matchhook[NG_HOOKSIZ]; /* hook name */
77 77
	u_int16_t	ethertype;	/* this ethertype to this hook */
78 78
};	
79 79

  
sys/netgraph/ksocket/ng_ksocket.c
83 83
	LIST_ENTRY(ng_ksocket_private)	siblings;
84 84
	u_int32_t	flags;
85 85
	u_int32_t	response_token;
86
	char		response_addr[NG_PATHLEN+1];
86
	char		response_addr[NG_PATHSIZ];
87 87
};
88 88
typedef struct ng_ksocket_private *priv_p;
89 89

  
......
568 568
	struct thread *td = curthread->td_proc ? curthread : &thread0;	/* XXX broken */
569 569
	const priv_p priv = node->private;
570 570
	struct ng_mesg *msg;
571
	char *s1, *s2, name[NG_HOOKLEN+1];
571
	char *s1, *s2, name[NG_HOOKSIZ];
572 572
	int family, type, protocol, error;
573 573

  
574 574
	/* Check if we're already connected */
sys/netgraph/netgraph/ng_base.c
323 323
static int
324 324
ng_load_module(const char *name)
325 325
{
326
	char *path, filename[NG_TYPELEN + 4];
326
	char *path, filename[NG_TYPESIZ + 3];
327 327
	linker_file_t lf;
328 328
	int error;
329 329

  
......
344 344
static int
345 345
ng_unload_module(const char *name)
346 346
{
347
	char filename[NG_TYPELEN + 4];
347
	char filename[NG_TYPESIZ + 3];
348 348
	linker_file_t lf;
349 349
	int error;
350 350

  
......
581 581
	int i;
582 582

  
583 583
	/* Check the name is valid */
584
	for (i = 0; i < NG_NODELEN + 1; i++) {
584
	for (i = 0; i < NG_NODESIZ; i++) {
585 585
		if (name[i] == '\0' || name[i] == '.' || name[i] == ':')
586 586
			break;
587 587
	}
......
903 903
	const size_t namelen = strlen(tp->name);
904 904

  
905 905
	/* Check version and type name fields */
906
	if (tp->version != NG_VERSION || namelen == 0 || namelen > NG_TYPELEN) {
906
	if (tp->version != NG_VERSION || namelen == 0 || namelen >= NG_TYPESIZ) {
907 907
		TRAP_ERROR;
908 908
		return (EINVAL);
909 909
	}
......
1092 1092
ng_path2node(node_p here, const char *address, node_p *destp, char **rtnp)
1093 1093
{
1094 1094
	const	node_p start = here;
1095
	char    fullpath[NG_PATHLEN + 1];
1095
	char    fullpath[NG_PATHSIZ];
1096 1096
	char   *nodename, *path, pbuf[2];
1097 1097
	node_p  node;
1098 1098
	char   *cp;
......
1173 1173

  
1174 1174
	/* Now compute return address, i.e., the path to the sender */
1175 1175
	if (rtnp != NULL) {
1176
		MALLOC(*rtnp, char *, NG_NODELEN + 2, M_NETGRAPH, M_NOWAIT);
1176
		MALLOC(*rtnp, char *, NG_NODESIZ + 1, M_NETGRAPH, M_NOWAIT);
1177 1177
		if (*rtnp == NULL) {
1178 1178
			TRAP_ERROR;
1179 1179
			return (ENOMEM);
......
1350 1350
		/* Fill in node info */
1351 1351
		ni = (struct nodeinfo *) rp->data;
1352 1352
		if (here->name != NULL)
1353
			strncpy(ni->name, here->name, NG_NODELEN);
1354
		strncpy(ni->type, here->type->name, NG_TYPELEN);
1353
			strlcpy(ni->name, here->name, NG_NODESIZ);
1354
		strlcpy(ni->type, here->type->name, NG_TYPESIZ);
1355 1355
		ni->id = ng_node2ID(here);
1356 1356
		ni->hooks = here->numhooks;
1357 1357
		*resp = rp;
......
1381 1381

  
1382 1382
		/* Fill in node info */
1383 1383
		if (here->name)
1384
			strncpy(ni->name, here->name, NG_NODELEN);
1385
		strncpy(ni->type, here->type->name, NG_TYPELEN);
1384
			strlcpy(ni->name, here->name, NG_NODESIZ);
1385
		strlcpy(ni->type, here->type->name, NG_TYPESIZ);
1386 1386
		ni->id = ng_node2ID(here);
1387 1387

  
1388 1388
		/* Cycle through the linked list of hooks */
......
1397 1397
			}
1398 1398
			if ((hook->flags & HK_INVALID) != 0)
1399 1399
				continue;
1400
			strncpy(link->ourhook, hook->name, NG_HOOKLEN);
1401
			strncpy(link->peerhook, hook->peer->name, NG_HOOKLEN);
1400
			strlcpy(link->ourhook, hook->name, NG_HOOKSIZ);
1401
			strlcpy(link->peerhook, hook->peer->name, NG_HOOKSIZ);
1402 1402
			if (hook->peer->node->name != NULL)
1403
				strncpy(link->nodeinfo.name,
1404
				    hook->peer->node->name, NG_NODELEN);
1405
			strncpy(link->nodeinfo.type,
1406
			   hook->peer->node->type->name, NG_TYPELEN);
1403
				strlcpy(link->nodeinfo.name,
1404
				    hook->peer->node->name, NG_NODESIZ);
1405
			strlcpy(link->nodeinfo.type,
1406
			   hook->peer->node->type->name, NG_TYPESIZ);
1407 1407
			link->nodeinfo.id = ng_node2ID(hook->peer->node);
1408 1408
			link->nodeinfo.hooks = hook->peer->node->numhooks;
1409 1409
			ni->hooks++;
......
1461 1461
			if (!unnamed && node->name == NULL)
1462 1462
				continue;
1463 1463
			if (node->name != NULL)
1464
				strncpy(np->name, node->name, NG_NODELEN);
1465
			strncpy(np->type, node->type->name, NG_TYPELEN);
1464
				strlcpy(np->name, node->name, NG_NODESIZ);
1465
			strlcpy(np->type, node->type->name, NG_TYPESIZ);
1466 1466
			np->id = ng_node2ID(node);
1467 1467
			np->hooks = node->numhooks;
1468 1468
			nl->numnames++;
......
1510 1510
				    __func__, "types");
1511 1511
				break;
1512 1512
			}
1513
			strncpy(tp->type_name, type->name, NG_TYPELEN);
1513
			strlcpy(tp->type_name, type->name, NG_TYPESIZ);
1514 1514
			tp->numnodes = type->refs - 1; /* don't count list */
1515 1515
			tl->numtypes++;
1516 1516
		}
sys/netgraph/netgraph/ng_parse.c
820 820
};
821 821

  
822 822
const struct ng_parse_fixedstring_info ng_parse_nodebuf_info = {
823
	NG_NODELEN + 1
823
	NG_NODESIZ
824 824
};
825 825
const struct ng_parse_type ng_parse_nodebuf_type = {
826 826
	&ng_parse_fixedstring_type,
......
828 828
};
829 829

  
830 830
const struct ng_parse_fixedstring_info ng_parse_hookbuf_info = {
831
	NG_HOOKLEN + 1
831
	NG_HOOKSIZ
832 832
};
833 833
const struct ng_parse_type ng_parse_hookbuf_type = {
834 834
	&ng_parse_fixedstring_type,
......
836 836
};
837 837

  
838 838
const struct ng_parse_fixedstring_info ng_parse_pathbuf_info = {
839
	NG_PATHLEN + 1
839
	NG_PATHSIZ
840 840
};
841 841
const struct ng_parse_type ng_parse_pathbuf_type = {
842 842
	&ng_parse_fixedstring_type,
......
844 844
};
845 845

  
846 846
const struct ng_parse_fixedstring_info ng_parse_typebuf_info = {
847
	NG_TYPELEN + 1
847
	NG_TYPESIZ
848 848
};
849 849
const struct ng_parse_type ng_parse_typebuf_type = {
850 850
	&ng_parse_fixedstring_type,
......
852 852
};
853 853

  
854 854
const struct ng_parse_fixedstring_info ng_parse_cmdbuf_info = {
855
	NG_CMDSTRLEN + 1
855
	NG_CMDSTRSIZ
856 856
};
857 857
const struct ng_parse_type ng_parse_cmdbuf_type = {
858 858
	&ng_parse_fixedstring_type,
sys/netgraph/ng_device.c
98 98
	SLIST_HEAD(, ngd_connection) head;
99 99

  
100 100
	node_p node;
101
	char nodename[NG_NODELEN + 1];
101
	char nodename[NG_NODESIZ];
102 102
} ngd_softc;
103 103

  
104 104
/* helper definition */
sys/netgraph/ng_message.h
49 49
#endif
50 50

  
51 51
/* ASCII string size limits */
52
#define NG_TYPELEN	15	/* max type name len (16 with null) */
53
#define NG_HOOKLEN	15	/* max hook name len (16 with null) */
54
#define NG_NODELEN	15	/* max node name len (16 with null) */
55
#define NG_PATHLEN	511	/* max path len     (512 with null) */
56
#define NG_CMDSTRLEN	15	/* max command string (16 with null) */
52
#define NG_TYPESIZ	32	/* max type name len (including null) */
53
#define NG_HOOKSIZ	32	/* max hook name len (including null) */
54
#define NG_NODESIZ	32	/* max node name len (including null) */
55
#define NG_PATHSIZ	512	/* max path len (including null) */
56
#define NG_CMDSTRSIZ	32	/* max command string (including null) */
57 57
#define NG_TEXTRESPONSE 1024	/* allow this length for a text response */
58 58

  
59 59
/* A netgraph message */
......
66 66
		u_int32_t	token;			/* match with reply */
67 67
		u_int32_t	typecookie;		/* node's type cookie */
68 68
		u_int32_t	cmd;			/* command identifier */
69
		u_char		cmdstr[NG_CMDSTRLEN+1];	/* cmd string + \0 */
69
		u_char		cmdstr[NG_CMDSTRSIZ];	/* cmd string */
70 70
	} header;
71 71
	char	data[0];		/* placeholder for actual data */
72 72
};
......
122 122

  
123 123
/* Structure used for NGM_MKPEER */
124 124
struct ngm_mkpeer {
125
	char	type[NG_TYPELEN + 1];			/* peer type */
126
	char	ourhook[NG_HOOKLEN + 1];		/* hook name */
127
	char	peerhook[NG_HOOKLEN + 1];		/* peer hook name */
125
	char	type[NG_TYPESIZ];		/* peer type */
126
	char	ourhook[NG_HOOKSIZ];		/* hook name */
127
	char	peerhook[NG_HOOKSIZ];		/* peer hook name */
128 128
};
129 129

  
130 130
/* Keep this in sync with the above structure definition */
......
137 137

  
138 138
/* Structure used for NGM_CONNECT */
139 139
struct ngm_connect {
140
	char	path[NG_PATHLEN + 1];			/* peer path */
141
	char	ourhook[NG_HOOKLEN + 1];		/* hook name */
142
	char	peerhook[NG_HOOKLEN + 1];		/* peer hook name */
140
	char	path[NG_PATHSIZ];		/* peer path */
141
	char	ourhook[NG_HOOKSIZ];		/* hook name */
142
	char	peerhook[NG_HOOKSIZ];		/* peer hook name */
143 143
};
144 144

  
145 145
/* Keep this in sync with the above structure definition */
......
152 152

  
153 153
/* Structure used for NGM_NAME */
154 154
struct ngm_name {
155
	char	name[NG_NODELEN + 1];			/* node name */
155
	char	name[NG_NODESIZ];			/* node name */
156 156
};
157 157

  
158 158
/* Keep this in sync with the above structure definition */
......
163 163

  
164 164
/* Structure used for NGM_RMHOOK */
165 165
struct ngm_rmhook {
166
	char	ourhook[NG_HOOKLEN + 1];		/* hook name */
166
	char	ourhook[NG_HOOKSIZ];		/* hook name */
167 167
};
168 168

  
169 169
/* Keep this in sync with the above structure definition */
......
174 174

  
175 175
/* Structure used for NGM_NODEINFO */
176 176
struct nodeinfo {
177
	char		name[NG_NODELEN + 1];	/* node name (if any) */
178
        char    	type[NG_TYPELEN + 1];   /* peer type */
177
	char		name[NG_NODESIZ];	/* node name (if any) */
178
        char    	type[NG_TYPESIZ];	/* peer type */
179 179
	ng_ID_t		id;			/* unique identifier */
180 180
	u_int32_t	hooks;			/* number of active hooks */
181 181
};
......
191 191

  
192 192
/* Structure used for NGM_LISTHOOKS */
193 193
struct linkinfo {
194
	char		ourhook[NG_HOOKLEN + 1];	/* hook name */
195
	char		peerhook[NG_HOOKLEN + 1];	/* peer hook */
194
	char		ourhook[NG_HOOKSIZ];	/* hook name */
195
	char		peerhook[NG_HOOKSIZ];	/* peer hook */
196 196
	struct nodeinfo	nodeinfo;
197 197
};
198 198

  
......
231 231

  
232 232
/* Structure used for NGM_LISTTYPES */
233 233
struct typeinfo {
234
	char		type_name[NG_TYPELEN + 1];	/* name of type */
234
	char		type_name[NG_TYPESIZ];		/* name of type */
235 235
	u_int32_t	numnodes;			/* number alive */
236 236
};
237 237

  
sys/netgraph/ng_parse.h
398 398
/*
399 399
 * COMMONLY USED BOUNDED LENGTH STRING TYPES
400 400
 */
401
extern const struct ng_parse_type ng_parse_nodebuf_type;  /* NG_NODELEN + 1 */
402
extern const struct ng_parse_type ng_parse_hookbuf_type;  /* NG_HOOKLEN + 1 */
403
extern const struct ng_parse_type ng_parse_pathbuf_type;  /* NG_PATHLEN + 1 */
404
extern const struct ng_parse_type ng_parse_typebuf_type;  /* NG_TYPELEN + 1 */
405
extern const struct ng_parse_type ng_parse_cmdbuf_type;   /* NG_CMDSTRLEN + 1 */
401
extern const struct ng_parse_type ng_parse_nodebuf_type;  /* NG_NODESIZ */
402
extern const struct ng_parse_type ng_parse_hookbuf_type;  /* NG_HOOKSIZ */
403
extern const struct ng_parse_type ng_parse_pathbuf_type;  /* NG_PATHSIZ */
404
extern const struct ng_parse_type ng_parse_typebuf_type;  /* NG_TYPESIZ */
405
extern const struct ng_parse_type ng_parse_cmdbuf_type;   /* NG_CMDSTRSIZ */
406 406

  
407 407
/*
408 408
 * INTEGER TYPES
sys/netgraph/ppp/ng_ppp.c
560 560
		break;
561 561
	case NGM_VJC_COOKIE:
562 562
	    {
563
		char path[NG_PATHLEN + 1];
563
		char path[NG_PATHSIZ];
564 564
		node_p origNode;
565 565

  
566 566
		if ((error = ng_path2node(node, raddr, &origNode, NULL)) != 0)
sys/netgraph/pppoe/ng_pppoe.c
142 142
	hook_p  		hook;
143 143
	u_int16_t		Session_ID;
144 144
	enum state		state;
145
	char			creator[NG_NODELEN + 1]; /* who to notify */
145
	char			creator[NG_NODESIZ]; /* who to notify */
146 146
	struct pppoe_full_hdr	pkt_hdr;	/* used when connected */
147 147
	negp			neg;		/* used when negotiating */
148 148
	/*struct sess_con	*hash_next;*/	/* not yet used */
......
685 685
			neg->pkt->pkt_header.ph.sid = 0x0000;
686 686
			neg->timeout = 0;
687 687

  
688
			strncpy(sp->creator, retaddr, NG_NODELEN);
689
			sp->creator[NG_NODELEN] = '\0';
688
			strlcpy(sp->creator, retaddr, NG_NODESIZ);
690 689
		}
691 690
		switch (msg->header.cmd) {
692 691
		case NGM_PPPOE_GET_STATUS:
......
849 848
		return (ENOMEM);
850 849

  
851 850
	sts = (struct ngpppoe_sts *)msg->data;
852
	tlen = min(NG_HOOKLEN, ntohs(tag->tag_len));
851
	tlen = min(NG_HOOKSIZ - 1, ntohs(tag->tag_len));
853 852
	strncpy(sts->hook, tag->tag_data, tlen);
854 853
	sts->hook[tlen] = '\0';
855 854
	error = ng_send_msg(sp->hook->node, msg, sp->creator, NULL);
......
1676 1675
	if (msg == NULL)
1677 1676
		return (ENOMEM);
1678 1677
	sts = (struct ngpppoe_sts *)msg->data;
1679
	strncpy(sts->hook, sp->hook->name, NG_HOOKLEN + 1);
1678
	strlcpy(sts->hook, sp->hook->name, NG_HOOKSIZ);
1680 1679
	error = ng_send_msg(sp->hook->node, msg, sp->creator, NULL);
1681 1680
	return (error);
1682 1681
}
sys/netgraph/pppoe/ng_pppoe.h
109 109
 * and begin negotiation.
110 110
 */
111 111
struct ngpppoe_init_data {
112
	char	hook[NG_HOOKLEN + 1];	/* hook to monitor on */
113
	u_int16_t	data_len;		/* Length of the service name */
112
	char	hook[NG_HOOKSIZ];	/* hook to monitor on */
113
	u_int16_t	data_len;	/* Length of the service name */
114 114
	char	data[0];		/* init data goes here */
115 115
};
116 116

  
......
120 120
 * to whoever requested the connection. (close may use this too).
121 121
 */
122 122
struct ngpppoe_sts {
123
	char	hook[NG_HOOKLEN + 1]; /* hook associated with event session */
123
	char	hook[NG_HOOKSIZ]; /* hook associated with event session */
124 124
};
125 125

  
126 126

  
sys/netgraph/socket/ng_socket.c
313 313
	meta_p  mp = NULL;
314 314
	int     len, error;
315 315
	hook_p  hook = NULL;
316
	char	hookname[NG_HOOKLEN + 1];
316
	char	hookname[NG_HOOKSIZ];
317 317

  
318 318
	if ((pcbp == NULL) || (control != NULL)) {
319 319
		error = EINVAL;
......
340 340
		 */
341 341
		hook = LIST_FIRST(&pcbp->sockdata->node->hooks);
342 342
	} else {
343
		if (len > NG_HOOKLEN) {
343
		if (len >= NG_HOOKSIZ) {
344 344
			error = EINVAL;
345 345
			goto release;
346 346
		}
......
803 803
	struct ngpcb *const pcbp = sockdata->datasock;
804 804
	struct socket *so;
805 805
	struct sockaddr_ng *addr;
806
	char *addrbuf[NG_HOOKLEN + 1 + 4];
806
	char *addrbuf[NG_HOOKSIZ + 4];
807 807
	int addrlen;
808 808

  
809 809
	/* If there is no data socket, black-hole it */
......
814 814
	so = pcbp->ng_socket;
815 815

  
816 816
	/* Get the return address into a sockaddr. */
817
	addrlen = strlen(hook->name);	/* <= NG_HOOKLEN */
817
	addrlen = strlen(hook->name);	/* <= NG_HOOKSIZ - 1 */
818 818
	addr = (struct sockaddr_ng *) addrbuf;
819 819
	addr->sg_len = addrlen + 3;
820 820
	addr->sg_family = AF_NETGRAPH;