View | Details | Raw Unified | Return to bug 233729
Collapse All | Expand All

(-)Makefile (-1 / +1 lines)
Lines 2-8 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	dht
4
PORTNAME=	dht
5
PORTVERSION=	0.22
5
PORTVERSION=	0.25
6
CATEGORIES=	devel
6
CATEGORIES=	devel
7
MASTER_SITES=	http://www.pps.univ-paris-diderot.fr/~jch/software/files/
7
MASTER_SITES=	http://www.pps.univ-paris-diderot.fr/~jch/software/files/
8
8
(-)distinfo (-2 / +3 lines)
Lines 1-2 Link Here
1
SHA256 (dht-0.22.tar.gz) = a3452322648660da43cabd34cff8505d8f655e988f31c467535ad1992c29ac3d
1
TIMESTAMP = 1543790466
2
SIZE (dht-0.22.tar.gz) = 27380
2
SHA256 (dht-0.25.tar.gz) = 1e0fd849a780699212f13052a4c9812d0af6f524c9cbf70a65e92eb3580372f6
3
SIZE (dht-0.25.tar.gz) = 29198
(-)files/patch-dht-example (-22 / +20 lines)
Lines 3-10 Link Here
3
3
4
	-mi
4
	-mi
5
5
6
--- dht-example.c	2014-05-03 14:37:50.000000000 -0400
6
--- dht-example.c	2018-02-09 16:44:37.000000000 -0500
7
+++ dht-example.c	2014-05-04 21:34:58.000000000 -0400
7
+++ dht-example.c	2018-12-02 17:47:54.158580000 -0500
8
@@ -12,4 +12,5 @@
8
@@ -12,4 +12,5 @@
9
 #include <fcntl.h>
9
 #include <fcntl.h>
10
 #include <sys/time.h>
10
 #include <sys/time.h>
Lines 11-18 Link Here
11
+#include <netinet/in.h>
11
+#include <netinet/in.h>
12
 #include <arpa/inet.h>
12
 #include <arpa/inet.h>
13
 #include <sys/types.h>
13
 #include <sys/types.h>
14
@@ -17,4 +18,7 @@
14
@@ -18,4 +19,7 @@
15
 #include <netdb.h>
15
 #include <signal.h>
16
 #include <sys/signal.h>
16
 #include <sys/signal.h>
17
+#include <signal.h>
17
+#include <signal.h>
18
+#include <unistd.h>
18
+#include <unistd.h>
Lines 19-27 Link Here
19
+#include <md5.h>
19
+#include <md5.h>
20
 
20
 
21
 #include "dht.h"
21
 #include "dht.h"
22
@@ -91,4 +95,11 @@
22
@@ -115,4 +119,11 @@
23
 static unsigned char buf[4096];
24
 
23
 
24
 
25
+typedef void (hashing_method)(void *, int,
25
+typedef void (hashing_method)(void *, int,
26
+	const void *, int,
26
+	const void *, int,
27
+	const void *, int,
27
+	const void *, int,
Lines 31-49 Link Here
31
+
31
+
32
 int
32
 int
33
 main(int argc, char **argv)
33
 main(int argc, char **argv)
34
@@ -112,9 +123,8 @@
34
@@ -137,6 +148,8 @@
35
     memset(&sin6, 0, sizeof(sin6));
36
     sin6.sin6_family = AF_INET6;
35
     sin6.sin6_family = AF_INET6;
37
-
36
 
38
-
39
+    hasher = crypt_hash;
37
+    hasher = crypt_hash;
40
 
38
+
41
     while(1) {
39
     while(1) {
42
-        opt = getopt(argc, argv, "q46b:i:");
40
-        opt = getopt(argc, argv, "q46b:i:");
43
+        opt = getopt(argc, argv, "q46b:i:m");
41
+        opt = getopt(argc, argv, "q46b:i:m");
44
         if(opt < 0)
42
         if(opt < 0)
45
             break;
43
             break;
46
@@ -143,4 +153,6 @@
44
@@ -165,4 +178,6 @@
47
             id_file = optarg;
45
             id_file = optarg;
48
             break;
46
             break;
49
+	case 'm':
47
+	case 'm':
Lines 50-57 Link Here
50
+            hasher = md5_hash;
48
+            hasher = md5_hash;
51
         default:
49
         default:
52
             goto usage;
50
             goto usage;
53
@@ -405,6 +417,7 @@
51
@@ -443,6 +458,7 @@
54
     
52
 
55
  usage:
53
  usage:
56
-    printf("Usage: dht-example [-q] [-4] [-6] [-i filename] [-b address]...\n"
54
-    printf("Usage: dht-example [-q] [-4] [-6] [-i filename] [-b address]...\n"
57
-           "                   port [address port]...\n");
55
-           "                   port [address port]...\n");
Lines 60-72 Link Here
60
+           "(Use -m to use MD5 digest instead of crypt()-based one)\n");
58
+           "(Use -m to use MD5 digest instead of crypt()-based one)\n");
61
     exit(1);
59
     exit(1);
62
 }
60
 }
63
@@ -420,25 +433,28 @@
61
@@ -465,25 +481,30 @@
64
 /* We need to provide a reasonably strong cryptographic hashing function.
62
 /* We need to provide a reasonably strong cryptographic hashing function.
65
    Here's how we'd do it if we had RSA's MD5 code. */
63
    Here's how we'd do it if we had RSA's MD5 code. */
66
-#if 0
64
-#if 0
67
-void
65
+
66
 void
68
-dht_hash(void *hash_return, int hash_size,
67
-dht_hash(void *hash_return, int hash_size,
69
+static void
70
+md5_hash(void *hash_return, int hash_size,
68
+md5_hash(void *hash_return, int hash_size,
71
          const void *v1, int len1,
69
          const void *v1, int len1,
72
          const void *v2, int len2,
70
          const void *v2, int len2,
Lines 89-106 Link Here
89
+    } else {
87
+    } else {
90
+        unsigned char digest[16];
88
+        unsigned char digest[16];
91
+        MD5Final(digest, &ctx);
89
+        MD5Final(digest, &ctx);
92
+	memcpy(hash_return, digest, hash_size);
90
+        memcpy(hash_return, digest, hash_size);
93
+    }
91
+    }
94
 }
92
 }
95
-#else
93
-#else
96
 /* But for this example, we might as well use something weaker. */
94
+
97
-void
95
 /* But for this toy example, we might as well use something weaker. */
96
 void
98
-dht_hash(void *hash_return, int hash_size,
97
-dht_hash(void *hash_return, int hash_size,
99
+static void
100
+crypt_hash(void *hash_return, int hash_size,
98
+crypt_hash(void *hash_return, int hash_size,
101
          const void *v1, int len1,
99
          const void *v1, int len1,
102
          const void *v2, int len2,
100
          const void *v2, int len2,
103
@@ -460,5 +476,14 @@
101
@@ -505,5 +526,14 @@
104
     strncpy(hash_return, crypt(key, "jc"), hash_size);
102
     strncpy(hash_return, crypt(key, "jc"), hash_size);
105
 }
103
 }
106
-#endif
104
-#endif
(-)files/patch-warns (-22 / +25 lines)
Lines 1-6 Link Here
1
--- dht.c	2011-07-25 17:59:36.000000000 -0400
1
--- dht.c	2018-02-09 16:44:37.000000000 -0500
2
+++ dht.c	2012-07-28 16:21:07.000000000 -0400
2
+++ dht.c	2018-12-02 18:00:11.873381000 -0500
3
@@ -356,5 +356,5 @@
3
@@ -365,5 +365,5 @@
4
     switch(sa->sa_family) {
4
     switch(sa->sa_family) {
5
     case AF_INET: {
5
     case AF_INET: {
6
-        struct sockaddr_in *sin = (struct sockaddr_in*)sa;
6
-        struct sockaddr_in *sin = (struct sockaddr_in*)sa;
Lines 7-13 Link Here
7
+        const struct sockaddr_in *sin = (const struct sockaddr_in*)sa;
7
+        const struct sockaddr_in *sin = (const struct sockaddr_in*)sa;
8
         const unsigned char *address = (const unsigned char*)&sin->sin_addr;
8
         const unsigned char *address = (const unsigned char*)&sin->sin_addr;
9
         return sin->sin_port == 0 ||
9
         return sin->sin_port == 0 ||
10
@@ -364,5 +364,5 @@
10
@@ -373,5 +373,5 @@
11
     }
11
     }
12
     case AF_INET6: {
12
     case AF_INET6: {
13
-        struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)sa;
13
-        struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)sa;
Lines 14-20 Link Here
14
+        const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6*)sa;
14
+        const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6*)sa;
15
         const unsigned char *address = (const unsigned char*)&sin6->sin6_addr;
15
         const unsigned char *address = (const unsigned char*)&sin6->sin6_addr;
16
         return sin6->sin6_port == 0 ||
16
         return sin6->sin6_port == 0 ||
17
@@ -1281,13 +1281,13 @@
17
@@ -1427,13 +1427,13 @@
18
     int i, len;
18
     int i, len;
19
     struct storage *st;
19
     struct storage *st;
20
-    unsigned char *ip;
20
-    unsigned char *ip;
Lines 33-39 Link Here
33
+        ip = (const unsigned char*)&sin6->sin6_addr;
33
+        ip = (const unsigned char*)&sin6->sin6_addr;
34
         len = 16;
34
         len = 16;
35
     } else {
35
     } else {
36
@@ -1406,15 +1406,15 @@
36
@@ -1552,15 +1552,15 @@
37
 make_token(const struct sockaddr *sa, int old, unsigned char *token_return)
37
 make_token(const struct sockaddr *sa, int old, unsigned char *token_return)
38
 {
38
 {
39
-    void *ip;
39
-    void *ip;
Lines 52-58 Link Here
52
+        const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6*)sa;
52
+        const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6*)sa;
53
         ip = &sin6->sin6_addr;
53
         ip = &sin6->sin6_addr;
54
         iplen = 16;
54
         iplen = 16;
55
@@ -1892,5 +1892,5 @@
55
@@ -2038,5 +2038,5 @@
56
         }
56
         }
57
 
57
 
58
-        if(((char*)buf)[buflen] != '\0') {
58
-        if(((char*)buf)[buflen] != '\0') {
Lines 59-65 Link Here
59
+        if(((const char*)buf)[buflen] != '\0') {
59
+        if(((const char*)buf)[buflen] != '\0') {
60
             debugf("Unterminated message.\n");
60
             debugf("Unterminated message.\n");
61
             errno = EINVAL;
61
             errno = EINVAL;
62
@@ -2743,5 +2743,5 @@
62
@@ -2905,5 +2905,5 @@
63
 
63
 
64
 #define CHECK(ptr, len)                                                 \
64
 #define CHECK(ptr, len)                                                 \
65
-    if(((unsigned char*)ptr) + (len) > (buf) + (buflen)) goto overflow;
65
-    if(((unsigned char*)ptr) + (len) > (buf) + (buflen)) goto overflow;
Lines 66-72 Link Here
66
+    if(((const unsigned char*)ptr) + (len) > (buf) + (buflen)) goto overflow;
66
+    if(((const unsigned char*)ptr) + (len) > (buf) + (buflen)) goto overflow;
67
 
67
 
68
     if(tid_return) {
68
     if(tid_return) {
69
@@ -2750,5 +2750,5 @@
69
@@ -2912,5 +2912,5 @@
70
             long l;
70
             long l;
71
             char *q;
71
             char *q;
72
-            l = strtol((char*)p + 3, &q, 10);
72
-            l = strtol((char*)p + 3, &q, 10);
Lines 73-107 Link Here
73
+            l = strtol((const char*)p + 3, &q, 10);
73
+            l = strtol((const char*)p + 3, &q, 10);
74
             if(q && *q == ':' && l > 0 && l < *tid_len) {
74
             if(q && *q == ':' && l > 0 && l < *tid_len) {
75
                 CHECK(q + 1, l);
75
                 CHECK(q + 1, l);
76
@@ -2782,5 +2782,5 @@
76
@@ -2944,5 +2944,5 @@
77
             long l;
77
             long l;
78
             char *q;
78
             char *q;
79
-            l = strtol((char*)p + 5, &q, 10);
79
-            l = strtol((char*)p + 7, &q, 10);
80
+            l = strtol((const char*)p + 5, &q, 10);
80
+            l = strtol((const char*)p + 7, &q, 10);
81
             if(q && *q == 'e' && l > 0 && l < 0x10000)
81
             if(q && *q == 'e' && l > 0 && l < 0x10000)
82
                 *port_return = l;
82
                 *port_return = l;
83
@@ -2804,5 +2804,5 @@
83
@@ -2957,5 +2957,5 @@
84
             long l;
84
             long l;
85
             char *q;
85
             char *q;
86
-            l = strtol((char*)p + 16, &q, 10);
87
+            l = strtol((const char*)p + 16, &q, 10);
88
             if(q && *q == 'e' && l > 0 && l < 0x10000)
89
                 *implied_port_return = l;
90
@@ -2979,5 +2979,5 @@
91
             long l;
92
             char *q;
86
-            l = strtol((char*)p + 7, &q, 10);
93
-            l = strtol((char*)p + 7, &q, 10);
87
+            l = strtol((const char*)p + 7, &q, 10);
94
+            l = strtol((const char*)p + 7, &q, 10);
88
             if(q && *q == ':' && l > 0 && l < *token_len) {
95
             if(q && *q == ':' && l > 0 && l < *token_len) {
89
                 CHECK(q + 1, l);
96
                 CHECK(q + 1, l);
90
@@ -2820,5 +2820,5 @@
97
@@ -2995,5 +2995,5 @@
91
             long l;
98
             long l;
92
             char *q;
99
             char *q;
93
-            l = strtol((char*)p + 7, &q, 10);
100
-            l = strtol((char*)p + 7, &q, 10);
94
+            l = strtol((const char*)p + 7, &q, 10);
101
+            l = strtol((const char*)p + 7, &q, 10);
95
             if(q && *q == ':' && l > 0 && l < *nodes_len) {
102
             if(q && *q == ':' && l > 0 && l <= *nodes_len) {
96
                 CHECK(q + 1, l);
103
                 CHECK(q + 1, l);
97
@@ -2836,5 +2836,5 @@
104
@@ -3011,5 +3011,5 @@
98
             long l;
105
             long l;
99
             char *q;
106
             char *q;
100
-            l = strtol((char*)p + 8, &q, 10);
107
-            l = strtol((char*)p + 8, &q, 10);
101
+            l = strtol((const char*)p + 8, &q, 10);
108
+            l = strtol((const char*)p + 8, &q, 10);
102
             if(q && *q == ':' && l > 0 && l < *nodes6_len) {
109
             if(q && *q == ':' && l > 0 && l <= *nodes6_len) {
103
                 CHECK(q + 1, l);
110
                 CHECK(q + 1, l);
104
@@ -2855,8 +2855,8 @@
111
@@ -3030,5 +3030,5 @@
105
                 long l;
112
                 long l;
106
                 char *q;
113
                 char *q;
107
-                l = strtol((char*)buf + i, &q, 10);
114
-                l = strtol((char*)buf + i, &q, 10);
Lines 108-114 Link Here
108
+                l = strtol((const char*)buf + i, &q, 10);
115
+                l = strtol((const char*)buf + i, &q, 10);
109
                 if(q && *q == ':' && l > 0) {
116
                 if(q && *q == ':' && l > 0) {
110
                     CHECK(q + 1, l);
117
                     CHECK(q + 1, l);
111
-                    i = q + 1 + l - (char*)buf;
112
+                    i = q + 1 + l - (const char*)buf;
113
                     if(l == 6) {
114
                         if(j + l > *values_len)

Return to bug 233729