fix: resolve_bootstrap_node() not checking net_getipport() returned count correctly

doc: improve inline docu of return of net_getipport
This commit is contained in:
Green Sky 2022-12-02 18:35:27 +01:00
parent d222d708b5
commit 88ffd1a649
No known key found for this signature in database
3 changed files with 5 additions and 4 deletions

View File

@ -1 +1 @@
1fadb7de1ccf46186e33c13343e2c67f4c84e78fadfbfbbc8f3ce70e670907f2 /usr/local/bin/tox-bootstrapd
3d28c914487efaae4336af17b221049c73249fb917d672f5ae6d9c092522a24f /usr/local/bin/tox-bootstrapd

View File

@ -544,8 +544,9 @@ bool net_connect(const Logger *log, Socket sock, const IP_Port *ip_port);
* Skip all addresses with socktype != type (use type = -1 to get all addresses)
* To correctly deallocate array memory use `net_freeipport()`
*
* return number of elements in res array
* and -1 on error.
* @return number of elements in res array.
* @retval 0 if res array empty.
* @retval -1 on error.
*/
non_null()
int32_t net_getipport(const char *node, IP_Port **res, int tox_type);

View File

@ -1008,7 +1008,7 @@ static int32_t resolve_bootstrap_node(Tox *tox, const char *host, uint16_t port,
const int32_t count = net_getipport(host, root, TOX_SOCK_DGRAM);
if (count == -1) {
if (count < 1) {
LOGGER_DEBUG(tox->m->log, "could not resolve bootstrap node '%s'", host);
net_freeipport(*root);
SET_ERROR_PARAMETER(error, TOX_ERR_BOOTSTRAP_BAD_HOST);