aboutsummaryrefslogtreecommitdiff
path: root/src/psyc
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2014-07-31 08:18:17 +0000
committerGabor X Toth <*@tg-x.net>2014-07-31 08:18:17 +0000
commit21db96c7ef17c463ae7127f48b29de0568424c2f (patch)
tree71ef583c23d2e3695c029541fdf939b786f16897 /src/psyc
parent40884377f3126bbecbfd3243d47224b3094914f9 (diff)
downloadgnunet-21db96c7ef17c463ae7127f48b29de0568424c2f.tar.gz
gnunet-21db96c7ef17c463ae7127f48b29de0568424c2f.zip
psyc, psycstore: operation result max error size
Diffstat (limited to 'src/psyc')
-rw-r--r--src/psyc/gnunet-service-psyc.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/psyc/gnunet-service-psyc.c b/src/psyc/gnunet-service-psyc.c
index 3adc34d2a..be5e4264e 100644
--- a/src/psyc/gnunet-service-psyc.c
+++ b/src/psyc/gnunet-service-psyc.c
@@ -255,11 +255,6 @@ struct Channel
255 uint8_t tmit_state; 255 uint8_t tmit_state;
256 256
257 /** 257 /**
258 * FIXME: needed?
259 */
260 uint8_t in_transmit;
261
262 /**
263 * Is this a channel master (#GNUNET_YES), or slave (#GNUNET_NO)? 258 * Is this a channel master (#GNUNET_YES), or slave (#GNUNET_NO)?
264 */ 259 */
265 uint8_t is_master; 260 uint8_t is_master;
@@ -609,17 +604,21 @@ client_send_result (struct GNUNET_SERVER_Client *client, uint64_t op_id,
609 int64_t result_code, const char *err_msg) 604 int64_t result_code, const char *err_msg)
610{ 605{
611 struct OperationResult *res; 606 struct OperationResult *res;
612 size_t err_len = 0; // FIXME: maximum length 607 size_t err_size = 0;
613 608
614 if (NULL != err_msg) 609 if (NULL != err_msg)
615 err_len = strlen (err_msg) + 1; 610 err_size = strnlen (err_msg,
616 res = GNUNET_malloc (sizeof (struct OperationResult) + err_len); 611 GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*res)) + 1;
612 res = GNUNET_malloc (sizeof (struct OperationResult) + err_size);
617 res->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_RESULT_CODE); 613 res->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_RESULT_CODE);
618 res->header.size = htons (sizeof (struct OperationResult) + err_len); 614 res->header.size = htons (sizeof (struct OperationResult) + err_size);
619 res->result_code = GNUNET_htonll (result_code + INT64_MAX + 1); 615 res->result_code = GNUNET_htonll (result_code + INT64_MAX + 1);
620 res->op_id = op_id; 616 res->op_id = op_id;
621 if (0 < err_len) 617 if (0 < err_size)
622 memcpy (&res[1], err_msg, err_len); 618 {
619 memcpy (&res[1], err_msg, err_size);
620 ((char *) &res[1])[err_size - 1] = '\0';
621 }
623 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 622 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
624 "%p Sending result to client for operation #%" PRIu64 ": " 623 "%p Sending result to client for operation #%" PRIu64 ": "
625 "%" PRId64 " (%s)\n", 624 "%" PRId64 " (%s)\n",