summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rps/gnunet-service-rps.c17
-rw-r--r--src/rps/gnunet-service-rps_sampler.c5
-rw-r--r--src/rps/rps-test_util.c14
3 files changed, 27 insertions, 9 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 83e06c2eb..7ad916840 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -1091,8 +1091,10 @@ add_peer_array_to_set (const struct GNUNET_PeerIdentity *peer_array,
{
unsigned int i;
if (NULL == peer_map)
- peer_map = GNUNET_CONTAINER_multipeermap_create (num_peers + 1,
- GNUNET_NO);
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Trying to add peers to an empty peermap.\n");
+ return;
+
for (i = 0 ; i < num_peers ; i++)
{
GNUNET_CONTAINER_multipeermap_put (peer_map,
@@ -1461,6 +1463,10 @@ handle_peer_push (void *cls,
{ /* We attack one single well-known peer - simply ignore */
return GNUNET_OK;
}
+ else
+ {
+ GNUNET_free (tmp_att_peer);
+ }
#endif /* ENABLE_MALICIOUS */
@@ -1951,6 +1957,7 @@ do_mal_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
}
/* Send PULLs to some peers to learn about additional peers to attack */
+ tmp_att_peer = att_peer_index;
for (i = 0 ; i < num_pushes * alpha ; i++)
{
if (att_peers_tail == tmp_att_peer)
@@ -2597,7 +2604,11 @@ run (void *cls,
gossip_list_size = 0;
/* file_name_view_log */
- GNUNET_DISK_directory_create ("/tmp/rps/");
+ if (GNUNET_OK != GNUNET_DISK_directory_create ("/tmp/rps/"))
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Failed to create directory /tmp/rps/\n");
+ }
size = (14 + strlen (GNUNET_i2s_full (&own_identity)) + 1) * sizeof (char);
file_name_view_log = GNUNET_malloc (size);
diff --git a/src/rps/gnunet-service-rps_sampler.c b/src/rps/gnunet-service-rps_sampler.c
index 88709d465..ed3677e8c 100644
--- a/src/rps/gnunet-service-rps_sampler.c
+++ b/src/rps/gnunet-service-rps_sampler.c
@@ -600,9 +600,6 @@ static void
sampler_empty (struct RPS_Sampler *sampler)
{
sampler_resize (sampler, 0);
- GNUNET_array_grow (sampler->trash_can,
- sampler->trash_can_size,
- 0);
}
@@ -923,6 +920,8 @@ RPS_sampler_get_n_rand_peers (struct RPS_Sampler *sampler,
void *cls, uint32_t num_peers)
{
GNUNET_assert (0 != sampler->sampler_size);
+ if (0 == num_peers)
+ return;
// TODO check if we have too much (distinct) sampled peers
uint32_t i;
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c
index a3354b0ac..5ba477bb7 100644
--- a/src/rps/rps-test_util.c
+++ b/src/rps/rps-test_util.c
@@ -82,6 +82,11 @@ to_file_ (char *file_name, char *line)
"Unable to write to file! (Size: %u, size2: %u)\n",
size,
size2);
+
+ if (GNUNET_YES != GNUNET_DISK_file_close (f))
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Unable to close file\n");
+
return;
}
@@ -149,9 +154,12 @@ create_file (const char *name)
if (0 > size)
LOG (GNUNET_ERROR_TYPE_WARNING, "Failed to create name_buf\n");
- GNUNET_DISK_directory_create (prefix);
-
- file_name = GNUNET_malloc (strlen (name_buf) + 6);
+ if (GNUNET_YES != GNUNET_DISK_directory_create (prefix))
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Could not create directory %s.\n",
+ prefix);
+ }
if (NULL == (file_name = GNUNET_DISK_mktemp (name_buf)))
LOG (GNUNET_ERROR_TYPE_WARNING, "Could not create file\n");