gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-twister] branch master updated: do never crash if AP


From: gnunet
Subject: [GNUnet-SVN] [taler-twister] branch master updated: do never crash if API is miss-used, simply log and return NULL (#5744)
Date: Sat, 15 Jun 2019 15:45:18 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository twister.

The following commit(s) were added to refs/heads/master by this push:
     new ad58257  do never crash if API is miss-used, simply log and return 
NULL (#5744)
ad58257 is described below

commit ad58257c5b5fc728faee55aaaea3ce747447a28a
Author: Christian Grothoff <address@hidden>
AuthorDate: Sat Jun 15 15:45:15 2019 +0200

    do never crash if API is miss-used, simply log and return NULL (#5744)
---
 src/twister/twister_api.c | 47 +++++++++++++++++++++++++++++------------------
 1 file changed, 29 insertions(+), 18 deletions(-)

diff --git a/src/twister/twister_api.c b/src/twister/twister_api.c
index faa879d..7087d62 100644
--- a/src/twister/twister_api.c
+++ b/src/twister/twister_api.c
@@ -324,6 +324,12 @@ TALER_TWISTER_flip_download
   struct TWISTER_FlipPath *src; //FIXME 'src' right name?
   uint16_t stralloc;
 
+  stralloc = strlen (path) + 1;
+  if (stralloc + sizeof (struct TWISTER_FlipPath) > UINT16_MAX)
+  {
+    GNUNET_break (0);
+    return NULL;
+  }
   op = GNUNET_new (struct TALER_TWISTER_Operation);
   op->h = h;
   op->cb = cb;
@@ -331,10 +337,6 @@ TALER_TWISTER_flip_download
   GNUNET_CONTAINER_DLL_insert_tail (h->op_head,
                                     h->op_tail,
                                     op);
-  stralloc = strlen (path) + 1;
-
-  GNUNET_assert
-    (stralloc + sizeof (struct TWISTER_FlipPath) < UINT16_MAX);
   env = GNUNET_MQ_msg_extra (src,
                              stralloc,
                              TWISTER_MESSAGE_TYPE_FLIP_PATH_DL);
@@ -373,6 +375,11 @@ TALER_TWISTER_flip_upload
   struct TWISTER_FlipPath *src; //FIXME 'src' right name?
   uint16_t stralloc = strlen (path) + 1;
 
+  if (stralloc + sizeof (struct TWISTER_FlipPath) > UINT16_MAX)
+  {
+    GNUNET_break (0);
+    return NULL;
+  }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
               "Will UL-flip: %s\n",
               path);
@@ -385,8 +392,6 @@ TALER_TWISTER_flip_upload
                                     h->op_tail,
                                     op);
 
-  GNUNET_assert
-    (stralloc + sizeof (struct TWISTER_FlipPath) < UINT16_MAX);
   env = GNUNET_MQ_msg_extra (src,
                              stralloc,
                              TWISTER_MESSAGE_TYPE_FLIP_PATH_UL);
@@ -423,6 +428,12 @@ TALER_TWISTER_delete_path
   struct TWISTER_DeletePath *src; //FIXME 'src' right name?
   uint16_t stralloc;
 
+  stralloc = strlen (path) + 1;
+  if (stralloc + sizeof (struct TWISTER_DeletePath) > UINT16_MAX)
+  {
+    GNUNET_break (0);
+    return NULL;
+  }
   op = GNUNET_new (struct TALER_TWISTER_Operation);
   op->h = h;
   op->cb = cb;
@@ -430,12 +441,6 @@ TALER_TWISTER_delete_path
   GNUNET_CONTAINER_DLL_insert_tail (h->op_head,
                                     h->op_tail,
                                     op);
-
-  stralloc = strlen (path) + 1;
-
-
-  GNUNET_assert
-    (stralloc + sizeof (struct TWISTER_DeletePath) < UINT16_MAX);
   env = GNUNET_MQ_msg_extra (src,
                              stralloc,
                              TWISTER_MESSAGE_TYPE_DELETE_PATH);
@@ -472,6 +477,12 @@ TALER_TWISTER_modify_path_dl (struct TALER_TWISTER_Handle 
*h,
   struct TWISTER_ModifyPath *src;
   uint16_t stralloc;
 
+  stralloc = strlen (path) + strlen (value) + 2;
+  if (sizeof (*src) + stralloc > UINT16_MAX)
+  {
+    GNUNET_break (0);
+    return NULL;
+  }
   op = GNUNET_new (struct TALER_TWISTER_Operation);
   op->h = h;
   op->cb = cb;
@@ -479,9 +490,6 @@ TALER_TWISTER_modify_path_dl (struct TALER_TWISTER_Handle 
*h,
   GNUNET_CONTAINER_DLL_insert_tail (h->op_head,
                                     h->op_tail,
                                     op);
-
-  stralloc = strlen (path) + strlen (value) + 2;
-  GNUNET_assert (sizeof (*src) + stralloc < UINT16_MAX);
   env = GNUNET_MQ_msg_extra (src,
                              stralloc,
                              TWISTER_MESSAGE_TYPE_MODIFY_PATH_DL);
@@ -521,6 +529,12 @@ TALER_TWISTER_modify_path_ul (struct TALER_TWISTER_Handle 
*h,
   struct TWISTER_ModifyPath *src;
   uint16_t stralloc;
 
+  stralloc = strlen (path) + strlen (value) + 2;
+  if (sizeof (*src) + stralloc > UINT16_MAX)
+  {
+    GNUNET_break (0);
+    return NULL;
+  }
   op = GNUNET_new (struct TALER_TWISTER_Operation);
   op->h = h;
   op->cb = cb;
@@ -528,9 +542,6 @@ TALER_TWISTER_modify_path_ul (struct TALER_TWISTER_Handle 
*h,
   GNUNET_CONTAINER_DLL_insert_tail (h->op_head,
                                     h->op_tail,
                                     op);
-
-  stralloc = strlen (path) + strlen (value) + 2;
-  GNUNET_assert (sizeof (*src) + stralloc < UINT16_MAX);
   env = GNUNET_MQ_msg_extra (src,
                              stralloc,
                              TWISTER_MESSAGE_TYPE_MODIFY_PATH_UL);

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

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