From 571a3aaa7cbba205d8697b9957dceaa6e13b720e Mon Sep 17 00:00:00 2001 From: Fonic Date: Sun, 8 Apr 2018 14:00:54 +0200 Subject: [PATCH 1/2] Fix incorrect parameter order for calloc in dht_init --- dht.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dht.c b/dht.c index 62ec649..343afca 100644 --- a/dht.c +++ b/dht.c @@ -1779,7 +1779,7 @@ dht_init(int s, int s6, const unsigned char *id, const unsigned char *v) numstorage = 0; if(s >= 0) { - buckets = calloc(sizeof(struct bucket), 1); + buckets = calloc(1, sizeof(struct bucket)); if(buckets == NULL) return -1; buckets->max_count = 128; @@ -1787,7 +1787,7 @@ dht_init(int s, int s6, const unsigned char *id, const unsigned char *v) } if(s6 >= 0) { - buckets6 = calloc(sizeof(struct bucket), 1); + buckets6 = calloc(1, sizeof(struct bucket)); if(buckets6 == NULL) return -1; buckets6->max_count = 128; From 5313b705e83272cf05ea26cf509a1ccee2e104f4 Mon Sep 17 00:00:00 2001 From: Fonic Date: Sun, 8 Apr 2018 14:01:54 +0200 Subject: [PATCH 2/2] Fix dht_insert_node not supporting IPv6 --- dht.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dht.c b/dht.c index 343afca..c752d13 100644 --- a/dht.c +++ b/dht.c @@ -2437,7 +2437,7 @@ dht_insert_node(const unsigned char *id, struct sockaddr *sa, int salen) { struct node *n; - if(sa->sa_family != AF_INET) { + if(sa->sa_family != AF_INET && sa->sa_family != AF_INET6) { errno = EAFNOSUPPORT; return -1; }