Changeset View
Changeset View
Standalone View
Standalone View
sys/netgraph/ng_socket.c
Show First 20 Lines • Show All 234 Lines • ▼ Show 20 Lines | ngc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, | ||||
} | } | ||||
/* Require destination as there may be >= 1 hooks on this node. */ | /* Require destination as there may be >= 1 hooks on this node. */ | ||||
if (addr == NULL) { | if (addr == NULL) { | ||||
error = EDESTADDRREQ; | error = EDESTADDRREQ; | ||||
goto release; | goto release; | ||||
} | } | ||||
if (sap->sg_len > NG_NODESIZ + offsetof(struct sockaddr_ng, sg_data)) { | |||||
melifaro: Nit: + offsetof(struct sockaddr_ng, sg_data) ? | |||||
Done Inline ActionsOk, I will convert the - 2 below as well then. markj: Ok, I will convert the `- 2` below as well then. | |||||
error = EINVAL; | |||||
goto release; | |||||
} | |||||
/* | /* | ||||
* Allocate an expendable buffer for the path, chop off | * Allocate an expendable buffer for the path, chop off | ||||
* the sockaddr header, and make sure it's NUL terminated. | * the sockaddr header, and make sure it's NUL terminated. | ||||
*/ | */ | ||||
len = sap->sg_len - 2; | len = sap->sg_len - offsetof(struct sockaddr_ng, sg_data); | ||||
path = malloc(len + 1, M_NETGRAPH_PATH, M_WAITOK); | path = malloc(len + 1, M_NETGRAPH_PATH, M_WAITOK); | ||||
bcopy(sap->sg_data, path, len); | bcopy(sap->sg_data, path, len); | ||||
path[len] = '\0'; | path[len] = '\0'; | ||||
/* | /* | ||||
* Move the actual message out of mbufs into a linear buffer. | * Move the actual message out of mbufs into a linear buffer. | ||||
* Start by adding up the size of the data. (could use mh_len?) | * Start by adding up the size of the data. (could use mh_len?) | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 161 Lines • ▼ Show 20 Lines | if ((pcbp == NULL) || (control != NULL)) { | ||||
error = EINVAL; | error = EINVAL; | ||||
goto release; | goto release; | ||||
} | } | ||||
if (pcbp->sockdata == NULL) { | if (pcbp->sockdata == NULL) { | ||||
error = ENOTCONN; | error = ENOTCONN; | ||||
goto release; | goto release; | ||||
} | } | ||||
if (sap == NULL) | if (sap == NULL) { | ||||
len = 0; /* Make compiler happy. */ | len = 0; /* Make compiler happy. */ | ||||
else | } else { | ||||
Done Inline ActionsSame here melifaro: Same here | |||||
len = sap->sg_len - 2; | if (sap->sg_len > NG_NODESIZ + | ||||
offsetof(struct sockaddr_ng, sg_data)) { | |||||
error = EINVAL; | |||||
goto release; | |||||
} | |||||
len = sap->sg_len - offsetof(struct sockaddr_ng, sg_data); | |||||
} | |||||
/* | /* | ||||
* If the user used any of these ways to not specify an address | * If the user used any of these ways to not specify an address | ||||
* then handle specially. | * then handle specially. | ||||
*/ | */ | ||||
if ((sap == NULL) || (len <= 0) || (*sap->sg_data == '\0')) { | if ((sap == NULL) || (len <= 0) || (*sap->sg_data == '\0')) { | ||||
if (NG_NODE_NUMHOOKS(pcbp->sockdata->node) != 1) { | if (NG_NODE_NUMHOOKS(pcbp->sockdata->node) != 1) { | ||||
error = EDESTADDRREQ; | error = EDESTADDRREQ; | ||||
▲ Show 20 Lines • Show All 787 Lines • Show Last 20 Lines |
Nit: + offsetof(struct sockaddr_ng, sg_data) ?