}
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,
{
uint16_t size = ntohs (opres->header.size);
const char *str = (const char *) &opres[1];
- if ( (sizeof (struct OperationResult) < size) &&
+ if ( (sizeof (*opres) < size) &&
('\0' != str[size - sizeof (*opres) - 1]) )
{
GNUNET_break (0);
check_result_state (void *cls, const struct StateResult *sres)
{
const char *name = (const char *) &sres[1];
+ uint16_t size = ntohs (sres->header.size);
uint16_t name_size = ntohs (sres->name_size);
- if (name_size <= 2 || '\0' != name[name_size - 1])
+ if (name_size <= 2
+ || size - sizeof (*sres) < name_size
+ || '\0' != name[name_size - 1])
{
LOG (GNUNET_ERROR_TYPE_ERROR,
"check_result_state: Received state result message with invalid name.\n");
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);
+ if (NULL == mod)
+ {
+ GNUNET_break_op (0);
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Invalid modifier in state result\n");
+ return GNUNET_SYSERR;
+ }
- if (NULL == mod || size - sizeof (*res) != mod_size)
+ uint16_t size = ntohs (res->header.size);
+ uint16_t mod_size = ntohs (mod->size);
+ if (size - sizeof (*res) != mod_size)
{
GNUNET_break_op (0);
LOG (GNUNET_ERROR_TYPE_WARNING,
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_op (0);
LOG (GNUNET_ERROR_TYPE_WARNING,