blob: 7ff86cc8be66758994e4621fedd470c6de7d6ee8 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001From cbcd19f38ae4b31c57c57ce3619b8d2674defb68 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sun, 28 Aug 2022 08:11:27 -0700
4Subject: [PATCH] netifaces: initialize msghdr in a portable way
5
6musl has padding bytes inside the msghdr struct which means initializing
7full structure will cause wrong assignments, doing partial assignment is
8more portable and assign the elements after that
9
10Fixes
11netifaces.c:1808:9: error: incompatible pointer to integer conversion initializing 'int' with an expression of type 'void *' [-Wint-conversion]
12 NULL,
13 ^~~~
14
15Upstream-Status: Inappropriate [Upstream Repo is read-only]
16Signed-off-by: Khem Raj <raj.khem@gmail.com>
17---
18 netifaces.c | 15 ++++++---------
19 1 file changed, 6 insertions(+), 9 deletions(-)
20
21diff --git a/netifaces.c b/netifaces.c
22index 839c42c..7da78e7 100644
23--- a/netifaces.c
24+++ b/netifaces.c
25@@ -1800,15 +1800,12 @@ gateways (PyObject *self)
26 do {
27 struct sockaddr_nl sanl_from;
28 struct iovec iov = { msgbuf, bufsize };
29- struct msghdr msghdr = {
30- &sanl_from,
31- sizeof(sanl_from),
32- &iov,
33- 1,
34- NULL,
35- 0,
36- 0
37- };
38+ struct msghdr msghdr = { 0 };
39+
40+ msghdr.msg_name = &sanl_from;
41+ msghdr.msg_namelen = sizeof(sanl_from);
42+ msghdr.msg_iov = &iov;
43+ msghdr.msg_iovlen = 1;
44 int nllen;
45
46 ret = recvmsg (s, &msghdr, 0);
47--
482.37.2
49