aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-06-18 11:00:55 +0200
committerChristian Grothoff <christian@grothoff.org>2019-06-18 11:00:55 +0200
commit136adb0f87a645b392fef587a06fc34d4698f3ed (patch)
tree115cb974f54d05870e80eb173328e86e62a51dc5
parent4cdc3b856356a4eee10534834d84df4159568739 (diff)
downloadgnunet-136adb0f87a645b392fef587a06fc34d4698f3ed.tar.gz
gnunet-136adb0f87a645b392fef587a06fc34d4698f3ed.zip
fix NPEs, off-by-one, etc
-rw-r--r--src/include/gnunet_common.h6
-rw-r--r--src/transport/gnunet-service-tng.c20
2 files changed, 12 insertions, 14 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index 6b48c81d8..66d0b8ac3 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -507,7 +507,6 @@ GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind,
507#define GNUNET_log_from(kind, comp, ...) \ 507#define GNUNET_log_from(kind, comp, ...) \
508 do \ 508 do \
509 { \ 509 { \
510 int log_line = __LINE__; \
511 static int log_call_enabled = GNUNET_LOG_CALL_STATUS; \ 510 static int log_call_enabled = GNUNET_LOG_CALL_STATUS; \
512 if ((GNUNET_EXTRA_LOGGING > 0) || \ 511 if ((GNUNET_EXTRA_LOGGING > 0) || \
513 ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \ 512 ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \
@@ -518,7 +517,7 @@ GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind,
518 (comp), \ 517 (comp), \
519 __FILE__, \ 518 __FILE__, \
520 __FUNCTION__, \ 519 __FUNCTION__, \
521 log_line); \ 520 __LINE__); \
522 if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \ 521 if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \
523 { \ 522 { \
524 GNUNET_log_skip (-1, GNUNET_NO); \ 523 GNUNET_log_skip (-1, GNUNET_NO); \
@@ -534,7 +533,6 @@ GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind,
534#define GNUNET_log(kind, ...) \ 533#define GNUNET_log(kind, ...) \
535 do \ 534 do \
536 { \ 535 { \
537 int log_line = __LINE__; \
538 static int log_call_enabled = GNUNET_LOG_CALL_STATUS; \ 536 static int log_call_enabled = GNUNET_LOG_CALL_STATUS; \
539 if ((GNUNET_EXTRA_LOGGING > 0) || \ 537 if ((GNUNET_EXTRA_LOGGING > 0) || \
540 ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \ 538 ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \
@@ -545,7 +543,7 @@ GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind,
545 NULL, \ 543 NULL, \
546 __FILE__, \ 544 __FILE__, \
547 __FUNCTION__, \ 545 __FUNCTION__, \
548 log_line); \ 546 __LINE__); \
549 if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \ 547 if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \
550 { \ 548 { \
551 GNUNET_log_skip (-1, GNUNET_NO); \ 549 GNUNET_log_skip (-1, GNUNET_NO); \
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index 803a8e518..bae187e7c 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -3872,11 +3872,12 @@ client_send_response (struct PendingMessage *pm)
3872{ 3872{
3873 struct TransportClient *tc = pm->client; 3873 struct TransportClient *tc = pm->client;
3874 struct VirtualLink *vl = pm->vl; 3874 struct VirtualLink *vl = pm->vl;
3875 struct GNUNET_MQ_Envelope *env;
3876 struct SendOkMessage *som;
3877 3875
3878 if (NULL != tc) 3876 if (NULL != tc)
3879 { 3877 {
3878 struct GNUNET_MQ_Envelope *env;
3879 struct SendOkMessage *som;
3880
3880 env = GNUNET_MQ_msg (som, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK); 3881 env = GNUNET_MQ_msg (som, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK);
3881 som->peer = vl->target; 3882 som->peer = vl->target;
3882 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3883 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -4593,11 +4594,11 @@ encapsulate_for_dv (struct DistanceVector *dv,
4593 char *path; 4594 char *path;
4594 4595
4595 path = GNUNET_strdup (GNUNET_i2s (&GST_my_identity)); 4596 path = GNUNET_strdup (GNUNET_i2s (&GST_my_identity));
4596 for (unsigned int i = 0; i <= num_hops; i++) 4597 for (unsigned int j = 0; j <= num_hops; j++)
4597 { 4598 {
4598 char *tmp; 4599 char *tmp;
4599 4600
4600 GNUNET_asprintf (&tmp, "%s-%s", path, GNUNET_i2s (&dhops[i])); 4601 GNUNET_asprintf (&tmp, "%s-%s", path, GNUNET_i2s (&dhops[j]));
4601 GNUNET_free (path); 4602 GNUNET_free (path);
4602 path = tmp; 4603 path = tmp;
4603 } 4604 }
@@ -5938,7 +5939,6 @@ handle_reliability_ack (void *cls,
5938{ 5939{
5939 struct CommunicatorMessageContext *cmc = cls; 5940 struct CommunicatorMessageContext *cmc = cls;
5940 const struct TransportCummulativeAckPayloadP *ack; 5941 const struct TransportCummulativeAckPayloadP *ack;
5941 struct PendingAcknowledgement *pa;
5942 unsigned int n_acks; 5942 unsigned int n_acks;
5943 uint32_t ack_counter; 5943 uint32_t ack_counter;
5944 5944
@@ -5947,7 +5947,7 @@ handle_reliability_ack (void *cls,
5947 ack = (const struct TransportCummulativeAckPayloadP *) &ra[1]; 5947 ack = (const struct TransportCummulativeAckPayloadP *) &ra[1];
5948 for (unsigned int i = 0; i < n_acks; i++) 5948 for (unsigned int i = 0; i < n_acks; i++)
5949 { 5949 {
5950 pa = 5950 struct PendingAcknowledgement *pa =
5951 GNUNET_CONTAINER_multiuuidmap_get (pending_acks, &ack[i].ack_uuid.value); 5951 GNUNET_CONTAINER_multiuuidmap_get (pending_acks, &ack[i].ack_uuid.value);
5952 if (NULL == pa) 5952 if (NULL == pa)
5953 { 5953 {
@@ -6886,7 +6886,7 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
6886 6886
6887 if (0 == (bi_history & (1 << i))) 6887 if (0 == (bi_history & (1 << i)))
6888 break; /* i-th hop not bi-directional, stop learning! */ 6888 break; /* i-th hop not bi-directional, stop learning! */
6889 if (i == nhops) 6889 if (i == nhops - 1)
6890 { 6890 {
6891 path[i + 2] = dvl->initiator; 6891 path[i + 2] = dvl->initiator;
6892 } 6892 }
@@ -8629,7 +8629,6 @@ select_best_pending_from_link (struct PendingMessageScoreContext *sc,
8629 this queue */) ) 8629 this queue */) )
8630 { 8630 {
8631 frag = GNUNET_YES; 8631 frag = GNUNET_YES;
8632 relb = GNUNET_NO; /* if we fragment, we never also reliability box */
8633 if (GNUNET_TRANSPORT_CC_RELIABLE == queue->tc->details.communicator.cc) 8632 if (GNUNET_TRANSPORT_CC_RELIABLE == queue->tc->details.communicator.cc)
8634 { 8633 {
8635 /* FIXME-FRAG-REL-UUID: we could use an optimized, shorter fragmentation 8634 /* FIXME-FRAG-REL-UUID: we could use an optimized, shorter fragmentation
@@ -8829,8 +8828,9 @@ transmit_on_queue (void *cls)
8829 "Fragmentation failed queue %s to %s for <%llu>, trying again\n", 8828 "Fragmentation failed queue %s to %s for <%llu>, trying again\n",
8830 queue->address, 8829 queue->address,
8831 GNUNET_i2s (&n->pid), 8830 GNUNET_i2s (&n->pid),
8832 pm->logging_uuid); 8831 sc.best->logging_uuid);
8833 schedule_transmit_on_queue (queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); 8832 schedule_transmit_on_queue (queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT);
8833 return;
8834 } 8834 }
8835 } 8835 }
8836 else if (GNUNET_YES == sc.relb) 8836 else if (GNUNET_YES == sc.relb)
@@ -8844,7 +8844,7 @@ transmit_on_queue (void *cls)
8844 "Reliability boxing failed queue %s to %s for <%llu>, trying again\n", 8844 "Reliability boxing failed queue %s to %s for <%llu>, trying again\n",
8845 queue->address, 8845 queue->address,
8846 GNUNET_i2s (&n->pid), 8846 GNUNET_i2s (&n->pid),
8847 pm->logging_uuid); 8847 sc.best->logging_uuid);
8848 schedule_transmit_on_queue (queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); 8848 schedule_transmit_on_queue (queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT);
8849 return; 8849 return;
8850 } 8850 }