fix(network): check len of netlinkResponse

pull/105/head
Alexis 2018-11-23 17:52:10 +01:00
parent 686bc4828e
commit 2e1f8b2fc5
1 changed files with 4 additions and 2 deletions

View File

@ -47,8 +47,10 @@ void waybar::modules::Network::worker()
{ {
thread_ = [this] { thread_ = [this] {
char buf[4096]; char buf[4096];
uint64_t len = netlinkResponse(sock_fd_, buf, sizeof(buf), auto len = netlinkResponse(sock_fd_, buf, sizeof(buf), RTMGRP_LINK | RTMGRP_IPV4_IFADDR);
RTMGRP_LINK | RTMGRP_IPV4_IFADDR); if (len == 0) {
return;
}
bool need_update = false; bool need_update = false;
bool new_addr = false; bool new_addr = false;
for (auto nh = reinterpret_cast<struct nlmsghdr *>(buf); NLMSG_OK(nh, len); for (auto nh = reinterpret_cast<struct nlmsghdr *>(buf); NLMSG_OK(nh, len);