aboutgitcodebugslistschat
diff options
context:
space:
mode:
-rw-r--r--udp.c4
-rw-r--r--util.h23
2 files changed, 27 insertions, 0 deletions
diff --git a/udp.c b/udp.c
index f425d14..98e3eaa 100644
--- a/udp.c
+++ b/udp.c
@@ -714,8 +714,10 @@ static void udp_sock_fill_data_v4(const struct ctx *c, int n,
b->uh.len = htons(udp4_l2_mh_sock[n].msg_len + sizeof(b->uh));
if (c->mode == MODE_PASTA) {
+ PRAGMA_STRINGOP_OVERREAD_IGNORE
if (write(c->fd_tap, &b->eh, sizeof(b->eh) + ip_len) < 0)
debug("tap write: %s", strerror(errno));
+ PRAGMA_STRINGOP_OVERREAD_IGNORE_POP
pcap((char *)&b->eh, sizeof(b->eh) + ip_len);
return;
@@ -813,8 +815,10 @@ static void udp_sock_fill_data_v6(const struct ctx *c, int n,
b->ip6h.hop_limit = 255;
if (c->mode == MODE_PASTA) {
+ PRAGMA_STRINGOP_OVERREAD_IGNORE
if (write(c->fd_tap, &b->eh, sizeof(b->eh) + ip_len) < 0)
debug("tap write: %s", strerror(errno));
+ PRAGMA_STRINGOP_OVERREAD_IGNORE_POP
pcap((char *)&b->eh, sizeof(b->eh) + ip_len);
return;
diff --git a/util.h b/util.h
index f85a87a..6f2c702 100644
--- a/util.h
+++ b/util.h
@@ -102,6 +102,29 @@ enum {
(void *)(arg)); \
} while (0)
+
+#ifdef __has_warning
+# if __has_warning("-Wstringop-overread")
+# define PRAGMA_STRINGOP_OVERREAD_IGNORE \
+ _Pragma("GCC diagnostic ignored \"-Wstringop-overread\"")
+# define PRAGMA_STRINGOP_OVERREAD_IGNORE_POP \
+ _Pragma("GCC diagnostic pop")
+# else
+# define PRAGMA_STRINGOP_OVERREAD_IGNORE
+# define PRAGMA_STRINGOP_OVERREAD_IGNORE_POP
+# endif
+#else
+# if defined(__GNUC__) && __GNUC__ >= 11
+# define PRAGMA_STRINGOP_OVERREAD_IGNORE \
+ _Pragma("GCC diagnostic ignored \"-Wstringop-overread\"")
+# define PRAGMA_STRINGOP_OVERREAD_IGNORE_POP \
+ _Pragma("GCC diagnostic pop")
+# else
+# define PRAGMA_STRINGOP_OVERREAD_IGNORE
+# define PRAGMA_STRINGOP_OVERREAD_IGNORE_POP
+# endif
+#endif
+
#if __BYTE_ORDER == __BIG_ENDIAN
#define L2_BUF_ETH_IP4_INIT \
{ \