Skip to content

Commit d29c42e

Browse files
committed
refactor: don't fully discard received DHT nodes.
This is mostly forward thinking, where we might introduce other ip families, in addition to ipv4, ipv6, tcp_ipv4 etc.
1 parent 21e2325 commit d29c42e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

toxcore/DHT.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ int unpack_nodes(Node_format *nodes, uint16_t max_num_nodes, uint16_t *processed
431431
const int ipp_size = unpack_ip_port(&nodes[num].ip_port, data + len_processed, length - len_processed, tcp_enabled);
432432

433433
if (ipp_size == -1) {
434-
return -1;
434+
break;
435435
}
436436

437437
len_processed += ipp_size;
@@ -450,6 +450,10 @@ int unpack_nodes(Node_format *nodes, uint16_t max_num_nodes, uint16_t *processed
450450
#endif /* NDEBUG */
451451
}
452452

453+
if (num == 0 && max_num_nodes > 0 && length > 0) {
454+
return -1;
455+
}
456+
453457
if (processed_data_len != nullptr) {
454458
*processed_data_len = len_processed;
455459
}

0 commit comments

Comments
 (0)