From 2e1f8b2fc56598332c13c72006c7843cf725a2a6 Mon Sep 17 00:00:00 2001 From: Alexis Date: Fri, 23 Nov 2018 17:52:10 +0100 Subject: [PATCH] fix(network): check len of netlinkResponse --- src/modules/network.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/network.cpp b/src/modules/network.cpp index adacf252..cf100b4b 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -47,8 +47,10 @@ void waybar::modules::Network::worker() { thread_ = [this] { char buf[4096]; - uint64_t len = netlinkResponse(sock_fd_, buf, sizeof(buf), - RTMGRP_LINK | RTMGRP_IPV4_IFADDR); + auto len = netlinkResponse(sock_fd_, buf, sizeof(buf), RTMGRP_LINK | RTMGRP_IPV4_IFADDR); + if (len == 0) { + return; + } bool need_update = false; bool new_addr = false; for (auto nh = reinterpret_cast(buf); NLMSG_OK(nh, len);