aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2016-09-22 11:35:38 +0000
committerGabor X Toth <*@tg-x.net>2016-09-22 11:35:38 +0000
commit76a029cc8d1dbf3d470079e98be1f3b7c4783ef0 (patch)
tree0448061d5cbfcab71265ec71b32ed83b8e591e9a /src
parent2f26cb57675966de7f04606fa83b0f0fc1dae46b (diff)
downloadgnunet-76a029cc8d1dbf3d470079e98be1f3b7c4783ef0.tar.gz
gnunet-76a029cc8d1dbf3d470079e98be1f3b7c4783ef0.zip
psyc,psycstore,social fixes
Diffstat (limited to 'src')
-rw-r--r--src/psyc/psyc_api.c11
-rw-r--r--src/psycstore/psycstore_api.c7
-rw-r--r--src/social/social_api.c17
3 files changed, 27 insertions, 8 deletions
diff --git a/src/psyc/psyc_api.c b/src/psyc/psyc_api.c
index 9c5832293..9769bb853 100644
--- a/src/psyc/psyc_api.c
+++ b/src/psyc/psyc_api.c
@@ -386,6 +386,11 @@ handle_channel_state_result (void *cls,
386 } 386 }
387 387
388 const struct GNUNET_MessageHeader *mod = GNUNET_MQ_extract_nested_mh (res); 388 const struct GNUNET_MessageHeader *mod = GNUNET_MQ_extract_nested_mh (res);
389 if (NULL == mod)
390 {
391 GNUNET_break_op (0);
392 return;
393 }
389 uint16_t mod_size = ntohs (mod->size); 394 uint16_t mod_size = ntohs (mod->size);
390 395
391 switch (ntohs (mod->type)) 396 switch (ntohs (mod->type))
@@ -397,9 +402,11 @@ handle_channel_state_result (void *cls,
397 402
398 const char *name = (const char *) &pmod[1]; 403 const char *name = (const char *) &pmod[1];
399 uint16_t name_size = ntohs (pmod->name_size); 404 uint16_t name_size = ntohs (pmod->name_size);
400 if ('\0' != name[name_size - 1]) 405 if (0 == name_size
406 || mod_size - sizeof (*pmod) < name_size
407 || '\0' != name[name_size - 1])
401 { 408 {
402 GNUNET_break (0); 409 GNUNET_break_op (0);
403 return; 410 return;
404 } 411 }
405 sr->var_cb (sr->cls, mod, name, name + name_size, 412 sr->var_cb (sr->cls, mod, name, name + name_size,
diff --git a/src/psycstore/psycstore_api.c b/src/psycstore/psycstore_api.c
index 7bbf2e3d8..480d594fc 100644
--- a/src/psycstore/psycstore_api.c
+++ b/src/psycstore/psycstore_api.c
@@ -122,7 +122,7 @@ check_result_code (void *cls, const struct OperationResult *opres)
122{ 122{
123 uint16_t size = ntohs (opres->header.size); 123 uint16_t size = ntohs (opres->header.size);
124 const char *str = (const char *) &opres[1]; 124 const char *str = (const char *) &opres[1];
125 if ( (sizeof (struct OperationResult) < size) && 125 if ( (sizeof (*opres) < size) &&
126 ('\0' != str[size - sizeof (*opres) - 1]) ) 126 ('\0' != str[size - sizeof (*opres) - 1]) )
127 { 127 {
128 GNUNET_break (0); 128 GNUNET_break (0);
@@ -244,9 +244,12 @@ static int
244check_result_state (void *cls, const struct StateResult *sres) 244check_result_state (void *cls, const struct StateResult *sres)
245{ 245{
246 const char *name = (const char *) &sres[1]; 246 const char *name = (const char *) &sres[1];
247 uint16_t size = ntohs (sres->header.size);
247 uint16_t name_size = ntohs (sres->name_size); 248 uint16_t name_size = ntohs (sres->name_size);
248 249
249 if (name_size <= 2 || '\0' != name[name_size - 1]) 250 if (name_size <= 2
251 || size - sizeof (*sres) < name_size
252 || '\0' != name[name_size - 1])
250 { 253 {
251 LOG (GNUNET_ERROR_TYPE_ERROR, 254 LOG (GNUNET_ERROR_TYPE_ERROR,
252 "check_result_state: Received state result message with invalid name.\n"); 255 "check_result_state: Received state result message with invalid name.\n");
diff --git a/src/social/social_api.c b/src/social/social_api.c
index e34774aae..f05e437ca 100644
--- a/src/social/social_api.c
+++ b/src/social/social_api.c
@@ -657,10 +657,17 @@ check_place_state_result (void *cls,
657 const struct GNUNET_OperationResultMessage *res) 657 const struct GNUNET_OperationResultMessage *res)
658{ 658{
659 const struct GNUNET_MessageHeader *mod = GNUNET_MQ_extract_nested_mh (res); 659 const struct GNUNET_MessageHeader *mod = GNUNET_MQ_extract_nested_mh (res);
660 uint16_t mod_size = ntohs (mod->size); 660 if (NULL == mod)
661 uint16_t size = ntohs (res->header.size); 661 {
662 GNUNET_break_op (0);
663 LOG (GNUNET_ERROR_TYPE_WARNING,
664 "Invalid modifier in state result\n");
665 return GNUNET_SYSERR;
666 }
662 667
663 if (NULL == mod || size - sizeof (*res) != mod_size) 668 uint16_t size = ntohs (res->header.size);
669 uint16_t mod_size = ntohs (mod->size);
670 if (size - sizeof (*res) != mod_size)
664 { 671 {
665 GNUNET_break_op (0); 672 GNUNET_break_op (0);
666 LOG (GNUNET_ERROR_TYPE_WARNING, 673 LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -700,7 +707,9 @@ handle_place_state_result (void *cls,
700 707
701 const char *name = (const char *) &pmod[1]; 708 const char *name = (const char *) &pmod[1];
702 uint16_t name_size = ntohs (pmod->name_size); 709 uint16_t name_size = ntohs (pmod->name_size);
703 if ('\0' != name[name_size - 1]) 710 if (0 == name_size
711 || mod_size - sizeof (*pmod) < name_size
712 || '\0' != name[name_size - 1])
704 { 713 {
705 GNUNET_break_op (0); 714 GNUNET_break_op (0);
706 LOG (GNUNET_ERROR_TYPE_WARNING, 715 LOG (GNUNET_ERROR_TYPE_WARNING,