This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Review at https://gerrit.osmocom.org/5347
tun.c: tun_addaddr: Fix segfault and wrong usage of tun_nlattr
First of all, dstaddr can be NULL, avoid copying it in that case.
Second, we want to copy the addr data, not the pointer. I tested it and
the IP was not added (not shown in ip addr) until I copied the content
instead of the address.
Change-Id: I8da637b155f0e913cab6c5b0dde355c9f33375b5
---
M lib/tun.c
1 file changed, 3 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/47/5347/1
diff --git a/lib/tun.c b/lib/tun.c
index d8e4b62..3081575 100644
--- a/lib/tun.c
+++ b/lib/tun.c
@@ -333,8 +333,9 @@
return -1;
}
- tun_nlattr(&req.n, sizeof(req), IFA_ADDRESS, addr, sizeof(addr));
- tun_nlattr(&req.n, sizeof(req), IFA_LOCAL, dstaddr, sizeof(dstaddr));
+ tun_nlattr(&req.n, sizeof(req), IFA_ADDRESS, addr, sizeof(*addr));
+ if (dstaddr)
+ tun_nlattr(&req.n, sizeof(req), IFA_LOCAL, dstaddr, sizeof(*dstaddr));
if ((fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE)) < 0) {
SYS_ERR(DTUN, LOGL_ERROR, errno, "socket() failed");
--
To view, visit https://gerrit.osmocom.org/5347
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8da637b155f0e913cab6c5b0dde355c9f33375b5
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>