diff options
Diffstat (limited to 'src/gns/gnunet-service-gns.c')
-rw-r--r-- | src/gns/gnunet-service-gns.c | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index c376ddfcc..71e744733 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2011-2018 GNUnet e.V. | 3 | Copyright (C) 2011-2018 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
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 | 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 General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | /** | 18 | /** |
21 | * @file gns/gnunet-service-gns.c | 19 | * @file gns/gnunet-service-gns.c |
@@ -296,7 +294,6 @@ client_disconnect_cb (void *cls, | |||
296 | clh); | 294 | clh); |
297 | GNUNET_free (clh); | 295 | GNUNET_free (clh); |
298 | } | 296 | } |
299 | |||
300 | GNUNET_free (gc); | 297 | GNUNET_free (gc); |
301 | } | 298 | } |
302 | 299 | ||
@@ -335,31 +332,47 @@ client_connect_cb (void *cls, | |||
335 | * @param rd the record data | 332 | * @param rd the record data |
336 | */ | 333 | */ |
337 | static void | 334 | static void |
338 | send_lookup_response (void* cls, | 335 | send_lookup_response (void *cls, |
339 | uint32_t rd_count, | 336 | uint32_t rd_count, |
340 | const struct GNUNET_GNSRECORD_Data *rd) | 337 | const struct GNUNET_GNSRECORD_Data *rd) |
341 | { | 338 | { |
342 | struct ClientLookupHandle *clh = cls; | 339 | struct ClientLookupHandle *clh = cls; |
340 | struct GnsClient *gc = clh->gc; | ||
343 | struct GNUNET_MQ_Envelope *env; | 341 | struct GNUNET_MQ_Envelope *env; |
344 | struct LookupResultMessage *rmsg; | 342 | struct LookupResultMessage *rmsg; |
345 | size_t len; | 343 | ssize_t len; |
346 | 344 | ||
347 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 345 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
348 | "Sending LOOKUP_RESULT message with %u results\n", | 346 | "Sending LOOKUP_RESULT message with %u results\n", |
349 | (unsigned int) rd_count); | 347 | (unsigned int) rd_count); |
350 | 348 | len = GNUNET_GNSRECORD_records_get_size (rd_count, | |
351 | len = GNUNET_GNSRECORD_records_get_size (rd_count, rd); | 349 | rd); |
350 | if (len < 0) | ||
351 | { | ||
352 | GNUNET_break (0); | ||
353 | GNUNET_SERVICE_client_drop (gc->client); | ||
354 | return; | ||
355 | } | ||
356 | if (len > UINT16_MAX - sizeof (*rmsg)) | ||
357 | { | ||
358 | GNUNET_break (0); | ||
359 | GNUNET_SERVICE_client_drop (gc->client); | ||
360 | return; | ||
361 | } | ||
352 | env = GNUNET_MQ_msg_extra (rmsg, | 362 | env = GNUNET_MQ_msg_extra (rmsg, |
353 | len, | 363 | len, |
354 | GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT); | 364 | GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT); |
355 | rmsg->id = clh->request_id; | 365 | rmsg->id = clh->request_id; |
356 | rmsg->rd_count = htonl (rd_count); | 366 | rmsg->rd_count = htonl (rd_count); |
357 | GNUNET_GNSRECORD_records_serialize (rd_count, rd, len, | 367 | GNUNET_assert (len == |
358 | (char*) &rmsg[1]); | 368 | GNUNET_GNSRECORD_records_serialize (rd_count, |
359 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(clh->gc->client), | 369 | rd, |
370 | len, | ||
371 | (char*) &rmsg[1])); | ||
372 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (gc->client), | ||
360 | env); | 373 | env); |
361 | GNUNET_CONTAINER_DLL_remove (clh->gc->clh_head, | 374 | GNUNET_CONTAINER_DLL_remove (gc->clh_head, |
362 | clh->gc->clh_tail, | 375 | gc->clh_tail, |
363 | clh); | 376 | clh); |
364 | GNUNET_free (clh); | 377 | GNUNET_free (clh); |
365 | GNUNET_STATISTICS_update (statistics, | 378 | GNUNET_STATISTICS_update (statistics, |
@@ -428,7 +441,6 @@ handle_lookup (void *cls, | |||
428 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 441 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
429 | "Received LOOKUP `%s' message\n", | 442 | "Received LOOKUP `%s' message\n", |
430 | name); | 443 | name); |
431 | |||
432 | clh = GNUNET_new (struct ClientLookupHandle); | 444 | clh = GNUNET_new (struct ClientLookupHandle); |
433 | GNUNET_CONTAINER_DLL_insert (gc->clh_head, | 445 | GNUNET_CONTAINER_DLL_insert (gc->clh_head, |
434 | gc->clh_tail, | 446 | gc->clh_tail, |