mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-12 19:06:36 +00:00
linux: remove nonsensical ip_addr loop break cond
This checks if a pointer offset from a heap-allocated buffer is NULL, which is only true if the buffer is NULL and the offset is zero. It appears to be attempting to check if an entry in an array of pointers is zero before dereferencing that entry, but the SIOCGIFCONF ioctl actually writes `struct ifreq` entries (not pointers to them) into the `ifc_buf` buffer. Furthermore, because `ifc_buf` is in a union with `struct ifreq *ifc_req`, we can simply access `ifc_req` instead of casting `ifc_buf` each time.
This commit is contained in:
parent
990c8277a5
commit
f3ffd17007
@ -578,11 +578,9 @@ void update_net_interfaces(FILE *net_dev_fp, bool is_first_update,
|
||||
for (unsigned int k = 0; k < conf.ifc_len / sizeof(struct ifreq); k++) {
|
||||
struct net_stat *ns2;
|
||||
|
||||
if (!(((struct ifreq *)conf.ifc_buf) + k)) break;
|
||||
|
||||
ns2 = get_net_stat(((struct ifreq *)conf.ifc_buf)[k].ifr_ifrn.ifrn_name,
|
||||
ns2 = get_net_stat(conf.ifc_req[k].ifr_ifrn.ifrn_name,
|
||||
nullptr, NULL);
|
||||
ns2->addr = ((struct ifreq *)conf.ifc_buf)[k].ifr_ifru.ifru_addr;
|
||||
ns2->addr = conf.ifc_req[k].ifr_ifru.ifru_addr;
|
||||
char temp_addr[18];
|
||||
snprintf(temp_addr, sizeof(temp_addr), "%u.%u.%u.%u, ",
|
||||
ns2->addr.sa_data[2] & 255, ns2->addr.sa_data[3] & 255,
|
||||
|
Loading…
Reference in New Issue
Block a user