Fix ff tools build error with gcc-13.2.0.

This commit is contained in:
fengbojiang 2024-10-12 21:09:39 +08:00
parent 38d9fdee68
commit 473c99d77e
4 changed files with 17 additions and 11 deletions

View File

@ -62,7 +62,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_ */

View File

@ -62,7 +62,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_ */

View File

@ -233,7 +233,10 @@ NgDeliverMsg(int cs, const char *path,
/* Prepare socket address */
sg->sg_family = AF_NETGRAPH;
/* XXX handle overflow */
strlcpy(sg->sg_data, path, NG_PATHSIZ);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow"
strncpy(sg->sg_data, path, NG_PATHSIZ);
#pragma GCC diagnostic pop
sg->sg_len = strlen(sg->sg_data) + 1 + NGSA_OVERHEAD;
/* Debugging */

View File

@ -108,7 +108,10 @@ WriteCmd(int ac, char **av)
/* Send data */
sag->sg_len = 3 + strlen(hook);
sag->sg_family = AF_NETGRAPH;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow"
strlcpy(sag->sg_data, hook, sizeof(sagbuf) - 2);
#pragma GCC diagnostic pop
if (sendto(dsock, buf, len,
0, (struct sockaddr *)sag, sag->sg_len) == -1) {
warn("writing to hook \"%s\"", hook);