diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-02-13 17:51:29 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-02-13 17:51:38 +0100 |
commit | 6b659c8a65c34d194d6440489442c411bb3f4c26 (patch) | |
tree | d7ec6931b2ef6267a964ec14819323dbb9833d57 /src/cadet | |
parent | aaca8161989c5af3f46251cd3e8d5fb531a5cb01 (diff) | |
download | gnunet-6b659c8a65c34d194d6440489442c411bb3f4c26.tar.gz gnunet-6b659c8a65c34d194d6440489442c411bb3f4c26.zip |
trying to fix #5532
Diffstat (limited to 'src/cadet')
-rw-r--r-- | src/cadet/cadet.h | 10 | ||||
-rw-r--r-- | src/cadet/cadet_api_get_path.c | 13 | ||||
-rw-r--r-- | src/cadet/gnunet-cadet.c | 16 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet.c | 10 |
4 files changed, 29 insertions, 20 deletions
diff --git a/src/cadet/cadet.h b/src/cadet/cadet.h index 51296ae50..f6cc860cc 100644 --- a/src/cadet/cadet.h +++ b/src/cadet/cadet.h | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
@@ -323,9 +323,9 @@ struct GNUNET_CADET_LocalInfoPath | |||
323 | struct GNUNET_MessageHeader header; | 323 | struct GNUNET_MessageHeader header; |
324 | 324 | ||
325 | /** | 325 | /** |
326 | * Zero. | 326 | * Offset of the peer that was requested. |
327 | */ | 327 | */ |
328 | uint32_t reserved GNUNET_PACKED; | 328 | uint32_t off GNUNET_PACKED; |
329 | }; | 329 | }; |
330 | 330 | ||
331 | 331 | ||
@@ -338,7 +338,7 @@ struct GNUNET_CADET_LocalInfoPeers | |||
338 | * Type: #GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS | 338 | * Type: #GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS |
339 | */ | 339 | */ |
340 | struct GNUNET_MessageHeader header; | 340 | struct GNUNET_MessageHeader header; |
341 | 341 | ||
342 | /** | 342 | /** |
343 | * Number of paths. | 343 | * Number of paths. |
344 | */ | 344 | */ |
@@ -348,7 +348,7 @@ struct GNUNET_CADET_LocalInfoPeers | |||
348 | * Do we have a tunnel toward this peer? | 348 | * Do we have a tunnel toward this peer? |
349 | */ | 349 | */ |
350 | int16_t tunnel GNUNET_PACKED; | 350 | int16_t tunnel GNUNET_PACKED; |
351 | 351 | ||
352 | /** | 352 | /** |
353 | * Shortest known path. | 353 | * Shortest known path. |
354 | */ | 354 | */ |
diff --git a/src/cadet/cadet_api_get_path.c b/src/cadet/cadet_api_get_path.c index 2f35e365e..fcc79c3d5 100644 --- a/src/cadet/cadet_api_get_path.c +++ b/src/cadet/cadet_api_get_path.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
@@ -66,7 +66,7 @@ struct GNUNET_CADET_GetPath | |||
66 | * Backoff for reconnect attempts. | 66 | * Backoff for reconnect attempts. |
67 | */ | 67 | */ |
68 | struct GNUNET_TIME_Relative backoff; | 68 | struct GNUNET_TIME_Relative backoff; |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * Peer we want information about. | 71 | * Peer we want information about. |
72 | */ | 72 | */ |
@@ -109,7 +109,7 @@ check_get_path (void *cls, | |||
109 | /** | 109 | /** |
110 | * Process a local peer info reply, pass info to the user. | 110 | * Process a local peer info reply, pass info to the user. |
111 | * | 111 | * |
112 | * @param cls Closure | 112 | * @param cls Closure |
113 | * @param message Message itself. | 113 | * @param message Message itself. |
114 | */ | 114 | */ |
115 | static void | 115 | static void |
@@ -118,9 +118,10 @@ handle_get_path (void *cls, | |||
118 | { | 118 | { |
119 | struct GNUNET_CADET_GetPath *gp = cls; | 119 | struct GNUNET_CADET_GetPath *gp = cls; |
120 | struct GNUNET_CADET_PeerPathDetail ppd; | 120 | struct GNUNET_CADET_PeerPathDetail ppd; |
121 | 121 | ||
122 | ppd.peer = gp->id; | 122 | ppd.peer = gp->id; |
123 | ppd.path = (const struct GNUNET_PeerIdentity *) &message[1]; | 123 | ppd.path = (const struct GNUNET_PeerIdentity *) &message[1]; |
124 | ppd.target_offset = ntohl (message->off); | ||
124 | ppd.path_length = (ntohs (message->header.size) - sizeof (*message)) | 125 | ppd.path_length = (ntohs (message->header.size) - sizeof (*message)) |
125 | / sizeof (struct GNUNET_PeerIdentity); | 126 | / sizeof (struct GNUNET_PeerIdentity); |
126 | gp->path_cb (gp->path_cb_cls, | 127 | gp->path_cb (gp->path_cb_cls, |
@@ -131,7 +132,7 @@ handle_get_path (void *cls, | |||
131 | /** | 132 | /** |
132 | * Process a local peer info reply, pass info to the user. | 133 | * Process a local peer info reply, pass info to the user. |
133 | * | 134 | * |
134 | * @param cls Closure | 135 | * @param cls Closure |
135 | * @param message Message itself. | 136 | * @param message Message itself. |
136 | */ | 137 | */ |
137 | static void | 138 | static void |
@@ -177,7 +178,7 @@ error_handler (void *cls, | |||
177 | gp); | 178 | gp); |
178 | } | 179 | } |
179 | 180 | ||
180 | 181 | ||
181 | /** | 182 | /** |
182 | * Reconnect to the service and try again. | 183 | * Reconnect to the service and try again. |
183 | * | 184 | * |
diff --git a/src/cadet/gnunet-cadet.c b/src/cadet/gnunet-cadet.c index dba517a7b..932d069a1 100644 --- a/src/cadet/gnunet-cadet.c +++ b/src/cadet/gnunet-cadet.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
@@ -103,7 +103,7 @@ static struct GNUNET_CADET_GetPath *gpo; | |||
103 | 103 | ||
104 | /** | 104 | /** |
105 | * Active peer listing operation. | 105 | * Active peer listing operation. |
106 | */ | 106 | */ |
107 | static struct GNUNET_CADET_PeersLister *plo; | 107 | static struct GNUNET_CADET_PeersLister *plo; |
108 | 108 | ||
109 | /** | 109 | /** |
@@ -220,7 +220,7 @@ shutdown_task (void *cls) | |||
220 | { | 220 | { |
221 | GNUNET_CADET_channel_destroy (ch); | 221 | GNUNET_CADET_channel_destroy (ch); |
222 | ch = NULL; | 222 | ch = NULL; |
223 | } | 223 | } |
224 | if (NULL != gpo) | 224 | if (NULL != gpo) |
225 | { | 225 | { |
226 | GNUNET_CADET_get_path_cancel (gpo); | 226 | GNUNET_CADET_get_path_cancel (gpo); |
@@ -306,12 +306,12 @@ read_stdio (void *cls) | |||
306 | if (GNUNET_NO == echo) | 306 | if (GNUNET_NO == echo) |
307 | { | 307 | { |
308 | // Use MQ's notification if too much data of stdin is pooring in too fast. | 308 | // Use MQ's notification if too much data of stdin is pooring in too fast. |
309 | if (STREAM_BUFFER_SIZE < sent_pkt) | 309 | if (STREAM_BUFFER_SIZE < sent_pkt) |
310 | { | 310 | { |
311 | GNUNET_MQ_notify_sent (env, mq_cb, cls); | 311 | GNUNET_MQ_notify_sent (env, mq_cb, cls); |
312 | sent_pkt = 0; | 312 | sent_pkt = 0; |
313 | } | 313 | } |
314 | else | 314 | else |
315 | { | 315 | { |
316 | listen_stdio (); | 316 | listen_stdio (); |
317 | } | 317 | } |
@@ -563,7 +563,7 @@ path_callback (void *cls, | |||
563 | ppd->path_length); | 563 | ppd->path_length); |
564 | for (unsigned int i = 0; i < ppd->path_length; i++) | 564 | for (unsigned int i = 0; i < ppd->path_length; i++) |
565 | FPRINTF (stdout, | 565 | FPRINTF (stdout, |
566 | "%s ", | 566 | (i == ppd->target_offset) ? "*%s* " : "%s ", |
567 | GNUNET_i2s (&ppd->path[i])); | 567 | GNUNET_i2s (&ppd->path[i])); |
568 | FPRINTF (stdout, | 568 | FPRINTF (stdout, |
569 | "\n"); | 569 | "\n"); |
@@ -626,7 +626,7 @@ show_peer (void *cls) | |||
626 | GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id, | 626 | GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id, |
627 | strlen (peer_id), | 627 | strlen (peer_id), |
628 | &pid.public_key)) | 628 | &pid.public_key)) |
629 | { | 629 | { |
630 | fprintf (stderr, | 630 | fprintf (stderr, |
631 | _("Invalid peer ID `%s'\n"), | 631 | _("Invalid peer ID `%s'\n"), |
632 | peer_id); | 632 | peer_id); |
@@ -859,7 +859,7 @@ main (int argc, | |||
859 | GNUNET_GETOPT_option_flag ('e', | 859 | GNUNET_GETOPT_option_flag ('e', |
860 | "echo", | 860 | "echo", |
861 | gettext_noop ("Activate echo mode"), | 861 | gettext_noop ("Activate echo mode"), |
862 | &echo), | 862 | &echo), |
863 | GNUNET_GETOPT_option_string ('o', | 863 | GNUNET_GETOPT_option_string ('o', |
864 | "open-port", | 864 | "open-port", |
865 | "SHARED_SECRET", | 865 | "SHARED_SECRET", |
diff --git a/src/cadet/gnunet-service-cadet.c b/src/cadet/gnunet-service-cadet.c index d64242943..e29330f99 100644 --- a/src/cadet/gnunet-service-cadet.c +++ b/src/cadet/gnunet-service-cadet.c | |||
@@ -886,6 +886,13 @@ path_info_iterator (void *cls, | |||
886 | path_size = sizeof (struct GNUNET_PeerIdentity) * path_length; | 886 | path_size = sizeof (struct GNUNET_PeerIdentity) * path_length; |
887 | if (sizeof (*resp) + path_size > UINT16_MAX) | 887 | if (sizeof (*resp) + path_size > UINT16_MAX) |
888 | { | 888 | { |
889 | /* try just giving the relevant path */ | ||
890 | path_length = GNUNET_MIN ((UINT16_MAX - sizeof (*resp)) / sizeof (struct GNUNET_PeerIdentity), | ||
891 | off); | ||
892 | path_size = sizeof (struct GNUNET_PeerIdentity) * path_length; | ||
893 | } | ||
894 | if (sizeof (*resp) + path_size > UINT16_MAX) | ||
895 | { | ||
889 | LOG (GNUNET_ERROR_TYPE_WARNING, | 896 | LOG (GNUNET_ERROR_TYPE_WARNING, |
890 | "Path of %u entries is too long for info message\n", | 897 | "Path of %u entries is too long for info message\n", |
891 | path_length); | 898 | path_length); |
@@ -899,9 +906,10 @@ path_info_iterator (void *cls, | |||
899 | /* Don't copy first peer. First peer is always the local one. Last | 906 | /* Don't copy first peer. First peer is always the local one. Last |
900 | * peer is always the destination (leave as 0, EOL). | 907 | * peer is always the destination (leave as 0, EOL). |
901 | */ | 908 | */ |
902 | for (unsigned int i = 0; i <= off; i++) | 909 | for (unsigned int i = 0; i < path_length; i++) |
903 | id[i] = *GCP_get_id (GCPP_get_peer_at_offset (path, | 910 | id[i] = *GCP_get_id (GCPP_get_peer_at_offset (path, |
904 | i)); | 911 | i)); |
912 | resp->off = htonl (off); | ||
905 | GNUNET_MQ_send (mq, | 913 | GNUNET_MQ_send (mq, |
906 | env); | 914 | env); |
907 | return GNUNET_YES; | 915 | return GNUNET_YES; |