[multicat-devel] [Git][videolan/multicat][master] 3 commits: util.c: suppress GCC warnings when accessing 'struct udprawpkt' fields

Christophe Massiot (@cmassiot) gitlab at videolan.org
Tue Jun 16 08:43:02 UTC 2026



Christophe Massiot pushed to branch master at VideoLAN / multicat


Commits:
1c3b7b98 by igutidze at 2026-06-15T22:26:50+04:00
util.c: suppress GCC warnings when accessing 'struct udprawpkt' fields

util.c: In function ‘RawFillHeaders’:
util.c:461:25: warning: taking address of packed member of ‘struct udprawpkt’ may result in an unaligned pointer value [-Waddress-of-packed-member]
  461 |     struct iphdr *iph = &(dgram->iph);
      |                         ^~~~~~~~~~~~~
util.c:465:27: warning: taking address of packed member of ‘struct udprawpkt’ may result in an unaligned pointer value [-Waddress-of-packed-member]
  465 |     struct udphdr *udph = &(dgram->udph);
      |                           ^~~~~~~~~~~~~~
- - - - -
67c795a8 by igutidze at 2026-06-15T22:27:08+04:00
util.c: avoid strncpy with destination length warning

util.c: In function ‘OpenSocketSafe’:
util.c:469:5: warning: ‘__builtin_strncpy’ specified bound 16 equals destination size [-Wstringop-truncation]
  469 |     strncpy(ipsrc_str, inet_ntoa(insrc), 16);
      |     ^
util.c:470:5: warning: ‘__builtin_strncpy’ specified bound 16 equals destination size [-Wstringop-truncation]
  470 |     strncpy(ipdst_str, inet_ntoa(indst), 16);
      |     ^

Co-authored-by: Clément Vasseur <clement.vasseur at gmail.com>

- - - - -
21429cd2 by Christophe Massiot at 2026-06-16T10:42:42+02:00
Merge branch 'igutidze-igutidze-patch-4'

- - - - -


1 changed file:

- util.c


Changes:

=====================================
util.c
=====================================
@@ -457,17 +457,29 @@ static void RawFillHeaders(struct udprawpkt *dgram,
 #if defined(__FreeBSD__)
     struct ip *iph = &(dgram->iph);
 #else
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
     struct iphdr *iph = &(dgram->iph);
+#pragma GCC diagnostic pop
 #endif
+#endif
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
     struct udphdr *udph = &(dgram->udph);
+#pragma GCC diagnostic pop
+#endif
 
 #ifdef DEBUG_SOCKET
     char ipsrc_str[16], ipdst_str[16];
     struct in_addr insrc, indst;
     insrc.s_addr = ipsrc;
     indst.s_addr = ipdst;
-    strncpy(ipsrc_str, inet_ntoa(insrc), 16);
-    strncpy(ipdst_str, inet_ntoa(indst), 16);
+    strncpy(ipsrc_str, inet_ntoa(insrc), 15);
+    ipsrc_str[15] = '\0';
+    strncpy(ipdst_str, inet_ntoa(indst), 15);
+    ipdst_str[15] = '\0';
     printf("Filling raw header (%p) (%s:%u -> %s:%u)\n", dgram, ipsrc_str, portsrc, ipdst_str, portdst);
 #endif
 



View it on GitLab: https://code.videolan.org/videolan/multicat/-/compare/c913225d0fd2e070fea56c1c14203c9ea59a7b8c...21429cd28e4b79bb09aae2713f78b4f1f4ec779b

-- 
View it on GitLab: https://code.videolan.org/videolan/multicat/-/compare/c913225d0fd2e070fea56c1c14203c9ea59a7b8c...21429cd28e4b79bb09aae2713f78b4f1f4ec779b
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the multicat-devel mailing list