mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-04 15:40:44 +00:00
netgraph: increase size of sockaddr_ng to match maximum node name
The ng_socket(4) node already writes more than declared size of the struct at least in the in ng_getsockaddr(). Make size match size of a node name. The value is pasted instead of including ng_message.h into ng_socket.h. This is external API and we want to keep it stable even if NG_NODESIZ is redefined in a kernel build. Reviewed by: afedorov Differential Revision: https://reviews.freebsd.org/D42690
This commit is contained in:
parent
c596126a5d
commit
4064a1108b
|
@ -42,7 +42,10 @@
|
|||
#ifndef _NETGRAPH_NG_MESSAGE_H_
|
||||
#define _NETGRAPH_NG_MESSAGE_H_
|
||||
|
||||
/* ASCII string size limits */
|
||||
/*
|
||||
* ASCII string size limits
|
||||
* Check with struct sockaddr_ng if changing.
|
||||
*/
|
||||
#define NG_TYPESIZ 32 /* max type name len (including null) */
|
||||
#define NG_HOOKSIZ 32 /* max hook name len (including null) */
|
||||
#define NG_NODESIZ 32 /* max node name len (including null) */
|
||||
|
|
|
@ -60,7 +60,7 @@ enum {
|
|||
struct sockaddr_ng {
|
||||
unsigned char sg_len; /* total length */
|
||||
sa_family_t sg_family; /* address family */
|
||||
char sg_data[14]; /* actually longer; address value */
|
||||
char sg_data[32]; /* see NG_NODESIZ in ng_message.h */
|
||||
};
|
||||
|
||||
#endif /* _NETGRAPH_NG_SOCKET_H_ */
|
||||
|
|
|
@ -53,12 +53,7 @@ ATF_TC_BODY(getsockname, tc)
|
|||
/* Named node. */
|
||||
ATF_REQUIRE(NgMkSockNode(name, &cs, NULL) == 0);
|
||||
ATF_REQUIRE(getsockname(cs, (struct sockaddr *)&sg, &len) == 0);
|
||||
#if 0
|
||||
/* sockaddr_ng truncates name now. */
|
||||
ATF_REQUIRE(strcmp(sg.sg_data, NAME) == 0);
|
||||
#else
|
||||
ATF_REQUIRE(strncmp(sg.sg_data, NAME, sizeof(sg.sg_data)) == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
|
|
Loading…
Reference in a new issue