diff --git a/platform/linux-generic/pktio/stats/ethtool_stats.c b/platform/linux-generic/pktio/stats/ethtool_stats.c index deb00bf59c..bbf0729f17 100644 --- a/platform/linux-generic/pktio/stats/ethtool_stats.c +++ b/platform/linux-generic/pktio/stats/ethtool_stats.c @@ -29,9 +29,11 @@ static struct ethtool_gstrings *get_stringset(int fd, struct ifreq *ifr) { - struct { + union { struct ethtool_sset_info hdr; - uint32_t buf[1]; /* overlaps with hdr.data[] */ + /* Reserve space for hdr.data. */ + uint8_t buf[sizeof(struct ethtool_sset_info) + + sizeof(((struct ethtool_sset_info *)0)->data[0])]; } sset_info; struct ethtool_drvinfo drvinfo; uint32_t len;