--- lib/libnetgraph/sock.c.orig	2007-06-03 23:38:54.000000000 +0100
+++ lib/libnetgraph/sock.c	2007-06-03 23:41:19.000000000 +0100
@@ -60,7 +60,7 @@
 int
 NgMkSockNode(const char *name, int *csp, int *dsp)
 {
-	char namebuf[NG_NODELEN + 1];
+	char namebuf[NG_NODESIZ];
 	int cs = -1;		/* control socket */
 	int ds = -1;		/* data socket */
 	int errnosv;
@@ -93,11 +93,11 @@
 gotNode:
 	/* Assign the node the desired name, if any */
 	if (name != NULL) {
-		u_char sbuf[NG_NODELEN + 3];
+		u_char sbuf[NG_NODESIZ + 2];
 		struct sockaddr_ng *const sg = (struct sockaddr_ng *) sbuf;
 
 		/* Assign name */
-		snprintf(sg->sg_data, NG_NODELEN + 1, "%s", name);
+		snprintf(sg->sg_data, NG_NODESIZ, "%s", name);
 		sg->sg_family = AF_NETGRAPH;
 		sg->sg_len = strlen(sg->sg_data) + 3;
 		if (bind(cs, (struct sockaddr *) sg, sg->sg_len) < 0) {
@@ -135,7 +135,7 @@
 
 	/* Create data socket if desired */
 	if (dsp != NULL) {
-		u_char sbuf[NG_NODELEN + 4];
+		u_char sbuf[NG_NODESIZ + 3];
 		struct sockaddr_ng *const sg = (struct sockaddr_ng *) sbuf;
 
 		/* Create data socket, initially just "floating" */
@@ -147,7 +147,7 @@
 		}
 
 		/* Associate the data socket with the node */
-		snprintf(sg->sg_data, NG_NODELEN + 2, "%s:", namebuf);
+		snprintf(sg->sg_data, NG_NODESIZ + 1, "%s:", namebuf);
 		sg->sg_family = AF_NETGRAPH;
 		sg->sg_len = strlen(sg->sg_data) + 3;
 		if (connect(ds, (struct sockaddr *) sg, sg->sg_len) < 0) {
@@ -211,7 +211,7 @@
 int
 NgRecvData(int ds, u_char * buf, size_t len, char *hook)
 {
-	u_char frombuf[NG_HOOKLEN + sizeof(struct sockaddr_ng)];
+	u_char frombuf[NG_HOOKSIZ - 1 + sizeof(struct sockaddr_ng)];
 	struct sockaddr_ng *const from = (struct sockaddr_ng *) frombuf;
 	int fromlen = sizeof(frombuf);
 	int rtn, errnosv;
@@ -228,7 +228,7 @@
 
 	/* Copy hook name */
 	if (hook != NULL)
-		snprintf(hook, NG_HOOKLEN + 1, "%s", from->sg_data);
+		snprintf(hook, NG_HOOKSIZ, "%s", from->sg_data);
 
 	/* Debugging */
 	if (_gNgDebugLevel >= 2) {
@@ -250,13 +250,13 @@
 int
 NgSendData(int ds, const char *hook, const u_char * buf, size_t len)
 {
-	u_char sgbuf[NG_HOOKLEN + sizeof(struct sockaddr_ng)];
+	u_char sgbuf[NG_HOOKSIZ - 1 + sizeof(struct sockaddr_ng)];
 	struct sockaddr_ng *const sg = (struct sockaddr_ng *) sgbuf;
 	int errnosv;
 
 	/* Set up destination hook */
 	sg->sg_family = AF_NETGRAPH;
-	snprintf(sg->sg_data, NG_HOOKLEN + 1, "%s", hook);
+	snprintf(sg->sg_data, NG_HOOKSIZ, "%s", hook);
 	sg->sg_len = strlen(sg->sg_data) + 3;
 
 	/* Debugging */
--- lib/libnetgraph/msg.c.orig	2007-06-03 23:38:47.000000000 +0100
+++ lib/libnetgraph/msg.c	2007-06-03 23:40:03.000000000 +0100
@@ -76,7 +76,7 @@
 	msg.header.token = gMsgId;
 	msg.header.flags = NGF_ORIG;
 	msg.header.cmd = cmd;
-	snprintf(msg.header.cmdstr, NG_CMDSTRLEN + 1, "cmd%d", cmd);
+	snprintf(msg.header.cmdstr, NG_CMDSTRSIZ, "cmd%d", cmd);
 
 	/* Deliver message */
 	if (NgDeliverMsg(cs, path, &msg, args, arglen) < 0)
@@ -175,7 +175,7 @@
 NgDeliverMsg(int cs, const char *path,
 	const struct ng_mesg *hdr, const void *args, size_t arglen)
 {
-	u_char sgbuf[NG_PATHLEN + 3];
+	u_char sgbuf[NG_PATHSIZ + 2];
 	struct sockaddr_ng *const sg = (struct sockaddr_ng *) sgbuf;
 	u_char *buf = NULL;
 	struct ng_mesg *msg;
@@ -203,7 +203,7 @@
 
 	/* Prepare socket address */
 	sg->sg_family = AF_NETGRAPH;
-	snprintf(sg->sg_data, NG_PATHLEN + 1, "%s", path);
+	snprintf(sg->sg_data, NG_PATHSIZ, "%s", path);
 	sg->sg_len = strlen(sg->sg_data) + 3;
 
 	/* Debugging */
@@ -240,7 +240,7 @@
 int
 NgRecvMsg(int cs, struct ng_mesg *rep, size_t replen, char *path)
 {
-	u_char sgbuf[NG_PATHLEN + sizeof(struct sockaddr_ng)];
+	u_char sgbuf[NG_PATHSIZ - 1 + sizeof(struct sockaddr_ng)];
 	struct sockaddr_ng *const sg = (struct sockaddr_ng *) sgbuf;
 	int len, sglen = sizeof(sgbuf);
 	int errnosv;
@@ -254,7 +254,7 @@
 		goto errout;
 	}
 	if (path != NULL)
-		snprintf(path, NG_PATHLEN + 1, "%s", sg->sg_data);
+		snprintf(path, NG_PATHSIZ, "%s", sg->sg_data);
 
 	/* Debugging */
 	if (_gNgDebugLevel >= 2) {
--- lib/libnetgraph/netgraph.3.orig	2007-06-03 23:55:34.000000000 +0100
+++ lib/libnetgraph/netgraph.3	2007-06-03 23:53:17.000000000 +0100
@@ -170,7 +170,7 @@
 If
 .Fa "path"
 is non-NULL, it must point to a buffer of at least
-.Dv "NG_PATHLEN + 1"
+.Dv "NG_PATHSIZ"
 bytes, which will be filled in (and NUL terminated) with the path to
 the node from which the message was received.
 .Pp
@@ -209,7 +209,7 @@
 which must be large enough to hold the entire packet.  If
 .Fa "hook"
 is non-NULL, it must point to a buffer of at least
-.Dv "NG_HOOKLEN + 1"
+.Dv "NG_HOOKSIZ"
 bytes, which will be filled in (and NUL terminated) with the name of
 the hook on which the data was received.
 .Pp
