diff options
-rw-r--r-- | src/scalarproduct/gnunet-scalarproduct.c | 15 | ||||
-rw-r--r-- | src/scalarproduct/gnunet-service-scalarproduct.c | 4 | ||||
-rw-r--r-- | src/scalarproduct/scalarproduct_api.c | 4 |
3 files changed, 12 insertions, 11 deletions
diff --git a/src/scalarproduct/gnunet-scalarproduct.c b/src/scalarproduct/gnunet-scalarproduct.c index 7fe6cf75c..5e95742e6 100644 --- a/src/scalarproduct/gnunet-scalarproduct.c +++ b/src/scalarproduct/gnunet-scalarproduct.c | |||
@@ -225,13 +225,13 @@ run (void *cls, | |||
225 | // get the length of the current element and replace , with null | 225 | // get the length of the current element and replace , with null |
226 | for (end = begin; *end && *end != ','; end++); | 226 | for (end = begin; *end && *end != ','; end++); |
227 | 227 | ||
228 | if (1 == sscanf (begin, "%" SCNd32",", &element)) | 228 | if (1 == sscanf (begin, "%" SCNd32 ",", &element)) |
229 | { | 229 | { |
230 | //element in the middle | 230 | //element in the middle |
231 | element_count++; | 231 | element_count++; |
232 | begin = end + 1; | 232 | begin = end + 1; |
233 | } | 233 | } |
234 | else if (*begin == 0) | 234 | else if (0 == *begin) |
235 | { | 235 | { |
236 | break; | 236 | break; |
237 | } | 237 | } |
@@ -244,25 +244,26 @@ run (void *cls, | |||
244 | while (1); | 244 | while (1); |
245 | if (0 == element_count) | 245 | if (0 == element_count) |
246 | { | 246 | { |
247 | 247 | LOG (GNUNET_ERROR_TYPE_ERROR, _ ("Need elements to compute the vectorproduct, got none.\n")); | |
248 | return; | 248 | return; |
249 | } | 249 | } |
250 | 250 | ||
251 | begin = input_elements; | 251 | begin = input_elements; |
252 | elements = GNUNET_malloc (sizeof (int32_t) * element_count); | 252 | elements = GNUNET_malloc (sizeof (int32_t) * element_count); |
253 | element_count = 0; | ||
253 | /* Read input_elements_peer1, and put in elements_peer1 array */ | 254 | /* Read input_elements_peer1, and put in elements_peer1 array */ |
254 | do | 255 | do |
255 | { | 256 | { |
256 | // get the length of the current element and replace , with null | 257 | // get the length of the current element and replace , with null |
257 | for (end = begin; *end && *end != ','; end++); | 258 | for (end = begin; *end && *end != ','; end++); |
258 | 259 | ||
259 | if (1 == sscanf (begin, "%" SCNd32",", &elements[element_count])) | 260 | if (1 == sscanf (begin, "%" SCNd32 ",", &elements[element_count])) |
260 | { | 261 | { |
261 | //element in the middle | 262 | //element in the middle |
262 | element_count++; | 263 | element_count++; |
263 | begin = end + 1; | 264 | begin = end + 1; |
264 | } | 265 | } |
265 | else if (*begin == 0) | 266 | else if (0 == *begin) |
266 | { | 267 | { |
267 | break; | 268 | break; |
268 | } | 269 | } |
@@ -270,7 +271,7 @@ run (void *cls, | |||
270 | while (1); | 271 | while (1); |
271 | 272 | ||
272 | mask_bytes = element_count / 8 + (element_count % 8 ? 1 : 0); | 273 | mask_bytes = element_count / 8 + (element_count % 8 ? 1 : 0); |
273 | mask = GNUNET_malloc ((element_count / 8) + 2); | 274 | mask = GNUNET_malloc ((element_count / 8) + 1); |
274 | 275 | ||
275 | /* Read input_mask_peer1 and read in mask_peer1 array */ | 276 | /* Read input_mask_peer1 and read in mask_peer1 array */ |
276 | if ((NULL != input_peer_id) && (NULL != input_mask)) | 277 | if ((NULL != input_peer_id) && (NULL != input_mask)) |
diff --git a/src/scalarproduct/gnunet-service-scalarproduct.c b/src/scalarproduct/gnunet-service-scalarproduct.c index bad8f570d..3c4746d2b 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct.c +++ b/src/scalarproduct/gnunet-service-scalarproduct.c | |||
@@ -2014,8 +2014,8 @@ invalid_msg: | |||
2014 | session->tunnel = NULL; | 2014 | session->tunnel = NULL; |
2015 | // send message with product to client | 2015 | // send message with product to client |
2016 | session->client_notification_task = | 2016 | session->client_notification_task = |
2017 | GNUNET_SCHEDULER_add_now (&prepare_client_response, | 2017 | GNUNET_SCHEDULER_add_now (&prepare_client_response, |
2018 | session); | 2018 | session); |
2019 | // the tunnel has done its job, terminate our connection and the tunnel | 2019 | // the tunnel has done its job, terminate our connection and the tunnel |
2020 | // the peer will be notified that the tunnel was destroyed via tunnel_destruction_handler | 2020 | // the peer will be notified that the tunnel was destroyed via tunnel_destruction_handler |
2021 | // just close the connection, as recommended by Christian | 2021 | // just close the connection, as recommended by Christian |
diff --git a/src/scalarproduct/scalarproduct_api.c b/src/scalarproduct/scalarproduct_api.c index 95aaaf86a..09c726c88 100644 --- a/src/scalarproduct/scalarproduct_api.c +++ b/src/scalarproduct/scalarproduct_api.c | |||
@@ -331,7 +331,7 @@ GNUNET_SCALARPRODUCT_response (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
331 | uint64_t i; | 331 | uint64_t i; |
332 | 332 | ||
333 | GNUNET_assert (GNUNET_SERVER_MAX_MESSAGE_SIZE >= sizeof (struct GNUNET_SCALARPRODUCT_client_request) | 333 | GNUNET_assert (GNUNET_SERVER_MAX_MESSAGE_SIZE >= sizeof (struct GNUNET_SCALARPRODUCT_client_request) |
334 | +element_count * sizeof (int32_t)); | 334 | + element_count * sizeof (int32_t)); |
335 | h = GNUNET_new (struct GNUNET_SCALARPRODUCT_ComputationHandle); | 335 | h = GNUNET_new (struct GNUNET_SCALARPRODUCT_ComputationHandle); |
336 | h->client = GNUNET_CLIENT_connect ("scalarproduct", cfg); | 336 | h->client = GNUNET_CLIENT_connect ("scalarproduct", cfg); |
337 | if (!h->client) | 337 | if (!h->client) |
@@ -351,7 +351,7 @@ GNUNET_SCALARPRODUCT_response (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
351 | return NULL; | 351 | return NULL; |
352 | } | 352 | } |
353 | 353 | ||
354 | size = sizeof (struct GNUNET_SCALARPRODUCT_client_request) +element_count * sizeof (int32_t); | 354 | size = sizeof (struct GNUNET_SCALARPRODUCT_client_request) + element_count * sizeof (int32_t); |
355 | 355 | ||
356 | h->cont_status = cont; | 356 | h->cont_status = cont; |
357 | h->cont_cls = cont_cls; | 357 | h->cont_cls = cont_cls; |