Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1 | From cbcd19f38ae4b31c57c57ce3619b8d2674defb68 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Sun, 28 Aug 2022 08:11:27 -0700 |
| 4 | Subject: [PATCH] netifaces: initialize msghdr in a portable way |
| 5 | |
| 6 | musl has padding bytes inside the msghdr struct which means initializing |
| 7 | full structure will cause wrong assignments, doing partial assignment is |
| 8 | more portable and assign the elements after that |
| 9 | |
| 10 | Fixes |
| 11 | netifaces.c:1808:9: error: incompatible pointer to integer conversion initializing 'int' with an expression of type 'void *' [-Wint-conversion] |
| 12 | NULL, |
| 13 | ^~~~ |
| 14 | |
| 15 | Upstream-Status: Inappropriate [Upstream Repo is read-only] |
| 16 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 17 | --- |
| 18 | netifaces.c | 15 ++++++--------- |
| 19 | 1 file changed, 6 insertions(+), 9 deletions(-) |
| 20 | |
| 21 | diff --git a/netifaces.c b/netifaces.c |
| 22 | index 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 | -- |
| 48 | 2.37.2 |
| 49 | |