gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r37973 - in gnunet/src: psyc psycstore social


From: gnunet
Subject: [GNUnet-SVN] r37973 - in gnunet/src: psyc psycstore social
Date: Thu, 22 Sep 2016 13:35:39 +0200

Author: tg
Date: 2016-09-22 13:35:38 +0200 (Thu, 22 Sep 2016)
New Revision: 37973

Modified:
   gnunet/src/psyc/psyc_api.c
   gnunet/src/psycstore/psycstore_api.c
   gnunet/src/social/social_api.c
Log:
psyc,psycstore,social fixes

Modified: gnunet/src/psyc/psyc_api.c
===================================================================
--- gnunet/src/psyc/psyc_api.c  2016-09-22 11:35:37 UTC (rev 37972)
+++ gnunet/src/psyc/psyc_api.c  2016-09-22 11:35:38 UTC (rev 37973)
@@ -386,6 +386,11 @@
   }
 
   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))
@@ -397,9 +402,11 @@
 
     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,

Modified: gnunet/src/psycstore/psycstore_api.c
===================================================================
--- gnunet/src/psycstore/psycstore_api.c        2016-09-22 11:35:37 UTC (rev 
37972)
+++ gnunet/src/psycstore/psycstore_api.c        2016-09-22 11:35:38 UTC (rev 
37973)
@@ -122,7 +122,7 @@
 {
   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);
@@ -244,9 +244,12 @@
 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");

Modified: gnunet/src/social/social_api.c
===================================================================
--- gnunet/src/social/social_api.c      2016-09-22 11:35:37 UTC (rev 37972)
+++ gnunet/src/social/social_api.c      2016-09-22 11:35:38 UTC (rev 37973)
@@ -657,10 +657,17 @@
                           const struct GNUNET_OperationResultMessage *res)
 {
   const struct GNUNET_MessageHeader *mod = GNUNET_MQ_extract_nested_mh (res);
+  if (NULL == mod)
+  {
+    GNUNET_break_op (0);
+    LOG (GNUNET_ERROR_TYPE_WARNING,
+         "Invalid modifier in state result\n");
+    return GNUNET_SYSERR;
+  }
+
+  uint16_t size = ntohs (res->header.size);
   uint16_t mod_size = ntohs (mod->size);
-  uint16_t size = ntohs (res->header.size);
-
-  if (NULL == mod || size - sizeof (*res) != mod_size)
+  if (size - sizeof (*res) != mod_size)
   {
     GNUNET_break_op (0);
     LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -700,7 +707,9 @@
 
     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,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]