Skip to content

Commit 171f080

Browse files
committed
M5 grade-2 tools: fix GCC 12 stringop-overflow guards
GCC 12 hardened -Wstringop-overflow detection emits -Werror on tools/libnetgraph/msg.c:240 (strncpy 512 bytes into 32-byte sg_data) and tools/ngctl/write.c:115 (strlcpy 254 bytes into 32-byte sg_data). Both files already had #pragma GCC diagnostic push/pop blocks but guarded under "#if __GNUC__ >= 13", missing GCC 12. Lower the guard to "#if __GNUC__ >= 12". Net effect: - tools/sbin/{ifconfig, route, ipfw, arp, ndp, ngctl, netstat} all link cleanly (24-25M each) - tools/{libnetgraph, libutil, libmemstat, libxo, sysctl, top, traffic, knictl, compat} 9 verify-only PASS - libffcompat.a: 22 .o / 301K
1 parent 5c7cc7e commit 171f080

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

tools/libnetgraph/msg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,12 @@ NgDeliverMsg(int cs, const char *path,
233233
/* Prepare socket address */
234234
sg->sg_family = AF_NETGRAPH;
235235
/* XXX handle overflow */
236-
#if __GNUC__ >= 13
236+
#if __GNUC__ >= 12
237237
#pragma GCC diagnostic push
238238
#pragma GCC diagnostic ignored "-Wstringop-overflow"
239239
#endif
240240
strncpy(sg->sg_data, path, NG_PATHSIZ);
241-
#if __GNUC__ >= 13
241+
#if __GNUC__ >= 12
242242
#pragma GCC diagnostic pop
243243
#endif
244244
sg->sg_len = strlen(sg->sg_data) + 1 + NGSA_OVERHEAD;

tools/ngctl/write.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ WriteCmd(int ac, char **av)
108108
/* Send data */
109109
sag->sg_len = 3 + strlen(hook);
110110
sag->sg_family = AF_NETGRAPH;
111-
#if __GNUC__ >= 13
111+
#if __GNUC__ >= 12
112112
#pragma GCC diagnostic push
113113
#pragma GCC diagnostic ignored "-Wstringop-overflow"
114114
#endif
115115
strlcpy(sag->sg_data, hook, sizeof(sagbuf) - 2);
116-
#if __GNUC__ >= 13
116+
#if __GNUC__ >= 12
117117
#pragma GCC diagnostic pop
118118
#endif
119119
if (sendto(dsock, buf, len,

0 commit comments

Comments
 (0)