pmsg = (struct GNUNET_PSYC_MessageHeader *) GNUNET_MQ_extract_nested_mh (res);
uint16_t size = ntohs (res->header.size);
- if (NULL == pmsg || size < sizeof (*res) + sizeof (*pmsg))
+ if ( (NULL == pmsg) ||
+ (size < sizeof (*res) + sizeof (*pmsg)) )
{ /* Error, message too small. */
GNUNET_break_op (0);
return GNUNET_SYSERR;
struct GNUNET_PSYC_Channel *chn = cls;
struct GNUNET_PSYC_MessageHeader *
pmsg = (struct GNUNET_PSYC_MessageHeader *) GNUNET_MQ_extract_nested_mh (res);
+ GNUNET_ResultCallback result_cb = NULL;
+ struct GNUNET_PSYC_HistoryRequest *hist = NULL;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"%p Received historic fragment for message #%" PRIu64 ".\n",
- chn, GNUNET_ntohll (pmsg->message_id));
-
- GNUNET_ResultCallback result_cb = NULL;
- struct GNUNET_PSYC_HistoryRequest *hist = NULL;
+ chn,
+ GNUNET_ntohll (pmsg->message_id));
if (GNUNET_YES != GNUNET_OP_get (chn->op,
GNUNET_ntohll (res->op_id),
const struct GNUNET_OperationResultMessage *res)
{
const struct GNUNET_MessageHeader *mod = GNUNET_MQ_extract_nested_mh (res);
- uint16_t mod_size = ntohs (mod->size);
- uint16_t size = ntohs (res->header.size);
+ uint16_t mod_size;
+ uint16_t size;
- if (NULL == mod || size - sizeof (*res) != mod_size)
+ if (NULL == mod)
+ {
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
+ mod_size = ntohs (mod->size);
+ size = ntohs (res->header.size);
+ if (size - sizeof (*res) != mod_size)
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
const struct GNUNET_MessageHeader *mod = GNUNET_MQ_extract_nested_mh (res);
+ if (NULL == mod)
+ {
+ GNUNET_break_op (0);
+ return;
+ }
uint16_t mod_size = ntohs (mod->size);
switch (ntohs (mod->type))
const char *name = (const char *) &pmod[1];
uint16_t name_size = ntohs (pmod->name_size);
- if ('\0' != name[name_size - 1])
+ if (0 == name_size
+ || mod_size - sizeof (*pmod) < name_size
+ || '\0' != name[name_size - 1])
{
- GNUNET_break (0);
+ GNUNET_break_op (0);
return;
}
sr->var_cb (sr->cls, mod, name, name + name_size,
check_master_join_request (void *cls,
const struct GNUNET_PSYC_JoinRequestMessage *req)
{
+ if ( ((sizeof (*req) + sizeof (struct GNUNET_PSYC_Message)) <= ntohs (req->header.size)) &&
+ (NULL == GNUNET_MQ_extract_nested_mh (req)) )
+ {
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
return GNUNET_OK;
}
join_msg = (struct GNUNET_PSYC_Message *) GNUNET_MQ_extract_nested_mh (req);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received join_msg of type %u and size %u.\n",
- ntohs (join_msg->header.type), ntohs (join_msg->header.size));
+ ntohs (join_msg->header.type),
+ ntohs (join_msg->header.size));
}
struct GNUNET_PSYC_JoinHandle *jh = GNUNET_malloc (sizeof (*jh));
if (NULL != chn->mq)
{
- struct GNUNET_MQ_Envelope *last = GNUNET_MQ_get_last_envelope (chn->mq);
- if (NULL != last)
+ struct GNUNET_MQ_Envelope *env = GNUNET_MQ_get_last_envelope (chn->mq);
+ if (NULL != env)
{
- GNUNET_MQ_notify_sent (last,
- (GNUNET_MQ_NotifyCallback) channel_cleanup, chn);
+ GNUNET_MQ_notify_sent (env, (GNUNET_SCHEDULER_TaskCallback) channel_cleanup, chn);
}
else
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Master client disconnected (%d), re-connecting\n",
(int) error);
- if (NULL != chn->mq)
- {
- GNUNET_MQ_destroy (chn->mq);
- chn->mq = NULL;
- }
if (NULL != chn->tmit)
{
GNUNET_PSYC_transmit_destroy (chn->tmit);
chn->tmit = NULL;
}
-
+ if (NULL != chn->mq)
+ {
+ GNUNET_MQ_destroy (chn->mq);
+ chn->mq = NULL;
+ }
chn->reconnect_task = GNUNET_SCHEDULER_add_delayed (chn->reconnect_delay,
master_reconnect,
mst);
GNUNET_MQ_handler_end ()
};
- chn->mq = GNUNET_CLIENT_connecT (chn->cfg, "psyc",
+ chn->mq = GNUNET_CLIENT_connect (chn->cfg, "psyc",
handlers, master_disconnected, mst);
GNUNET_assert (NULL != chn->mq);
chn->tmit = GNUNET_PSYC_transmit_create (chn->mq);
GNUNET_PSYC_MessagePartCallback message_part_cb,
void *cls)
{
- struct GNUNET_PSYC_Master *mst = GNUNET_malloc (sizeof (*mst));
+ struct GNUNET_PSYC_Master *mst = GNUNET_new (struct GNUNET_PSYC_Master);
struct GNUNET_PSYC_Channel *chn = &mst->chn;
+ struct MasterStartRequest *req;
- struct MasterStartRequest *req = GNUNET_malloc (sizeof (*req));
chn->connect_env = GNUNET_MQ_msg (req,
GNUNET_MESSAGE_TYPE_PSYC_MASTER_START);
req->channel_key = *channel_key;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Slave client disconnected (%d), re-connecting\n",
(int) error);
- if (NULL != chn->mq)
- {
- GNUNET_MQ_destroy (chn->mq);
- chn->mq = NULL;
- }
if (NULL != chn->tmit)
{
GNUNET_PSYC_transmit_destroy (chn->tmit);
chn->tmit = NULL;
}
+ if (NULL != chn->mq)
+ {
+ GNUNET_MQ_destroy (chn->mq);
+ chn->mq = NULL;
+ }
chn->reconnect_task = GNUNET_SCHEDULER_add_delayed (chn->reconnect_delay,
slave_reconnect,
slv);
GNUNET_MQ_handler_end ()
};
- chn->mq = GNUNET_CLIENT_connecT (chn->cfg, "psyc",
+ chn->mq = GNUNET_CLIENT_connect (chn->cfg, "psyc",
handlers, slave_disconnected, slv);
GNUNET_assert (NULL != chn->mq);
chn->tmit = GNUNET_PSYC_transmit_create (chn->mq);