Skip to content

Commit

Permalink
Merge pull request #3 from beyonddream/fix-hw-address-comparison-bug
Browse files Browse the repository at this point in the history
fix comparison of hw addresses to include null terminator
  • Loading branch information
beyonddream authored Nov 5, 2022
2 parents 6b52eea + 4f160ca commit 822c644
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions snowid_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ bool get_hw_addr_as_binary(uint64_t *workerid, char *interface)

family = ifa->ifa_addr->sa_family;

/* skip if socket doesn't support IPv6 */
/* skip if family is not link layer type */
if (family != IF_HW_FAMILY) {
continue;
}

/* skip loopback */
/* skip loopback - anything starting with lo */
if ((ifa->ifa_name == NULL) || strncmp(ifa->ifa_name, "lo", 2) == 0) {
continue;
}
Expand All @@ -88,7 +88,7 @@ bool get_hw_addr_as_binary(uint64_t *workerid, char *interface)

found = true;

if (interface != NULL && strncmp(ifa->ifa_name, interface, strlen(interface)) == 0) {
if (interface != NULL && strncmp(ifa->ifa_name, interface, strlen(interface) + 1) == 0) {
break;
}
}
Expand Down

0 comments on commit 822c644

Please sign in to comment.