gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: fix error in presentation handling


From: gnunet
Subject: [gnunet] branch master updated: fix error in presentation handling
Date: Fri, 25 Dec 2020 13:38:07 +0100

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

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 1e37e8edc fix error in presentation handling
1e37e8edc is described below

commit 1e37e8edc0c23674df6c2144e3f2d83e3dbc1bc2
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Fri Dec 25 21:37:28 2020 +0900

    fix error in presentation handling
---
 src/reclaim/gnunet-service-reclaim_tickets.c |  1 +
 src/reclaim/oidc_helper.c                    |  4 ++++
 src/reclaim/plugin_reclaim_attribute_basic.c |  2 +-
 src/reclaim/plugin_reclaim_credential_jwt.c  | 27 +++++++++++++++------------
 src/reclaim/reclaim_credential.c             |  4 +---
 5 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c 
b/src/reclaim/gnunet-service-reclaim_tickets.c
index 0b1730bec..ef2303bd7 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.c
+++ b/src/reclaim/gnunet-service-reclaim_tickets.c
@@ -1542,6 +1542,7 @@ filter_tickets_cb (void *cls,
                                      tih->presentations->list_tail,
                                      ple);
         GNUNET_free (cred);
+        break;
       }
     }
     if (GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION == rd[i].record_type)
diff --git a/src/reclaim/oidc_helper.c b/src/reclaim/oidc_helper.c
index a90d02d68..041a2fe47 100644
--- a/src/reclaim/oidc_helper.c
+++ b/src/reclaim/oidc_helper.c
@@ -202,11 +202,15 @@ generate_userinfo_json (const struct 
GNUNET_IDENTITY_PublicKey *sub_key,
     GNUNET_asprintf (&source_name,
                      "src%d",
                      i);
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "Adding new presentation source #%d\n", i);
     aggr_sources_jwt = json_object ();
     pres_val_str =
       GNUNET_RECLAIM_presentation_value_to_string (ple->presentation->type,
                                                    ple->presentation->data,
                                                    
ple->presentation->data_size);
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "Presentation is: %s\n", pres_val_str);
     json_object_set_new (aggr_sources_jwt,
                          GNUNET_RECLAIM_presentation_number_to_typename (
                            ple->presentation->type),
diff --git a/src/reclaim/plugin_reclaim_attribute_basic.c 
b/src/reclaim/plugin_reclaim_attribute_basic.c
index 286186a93..c87922886 100644
--- a/src/reclaim/plugin_reclaim_attribute_basic.c
+++ b/src/reclaim/plugin_reclaim_attribute_basic.c
@@ -82,7 +82,7 @@ basic_string_to_value (void *cls,
   {
   case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING:
     *data = GNUNET_strdup (s);
-    *data_size = strlen (s);
+    *data_size = strlen (s) + 1;
     return GNUNET_OK;
 
   default:
diff --git a/src/reclaim/plugin_reclaim_credential_jwt.c 
b/src/reclaim/plugin_reclaim_credential_jwt.c
index 6f52f3a4e..f30ead570 100644
--- a/src/reclaim/plugin_reclaim_credential_jwt.c
+++ b/src/reclaim/plugin_reclaim_credential_jwt.c
@@ -81,7 +81,7 @@ jwt_string_to_value (void *cls,
   {
   case GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT:
     *data = GNUNET_strdup (s);
-    *data_size = strlen (s);
+    *data_size = strlen (s) + 1;
     return GNUNET_OK;
 
   default:
@@ -151,7 +151,8 @@ jwt_number_to_typename (void *cls, uint32_t type)
  */
 struct GNUNET_RECLAIM_AttributeList *
 jwt_parse_attributes (void *cls,
-                      const char *data)
+                      const char *data,
+                      size_t data_size)
 {
   char *jwt_string;
   struct GNUNET_RECLAIM_AttributeList *attrs;
@@ -164,7 +165,7 @@ jwt_parse_attributes (void *cls,
 
   attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
 
-  jwt_string = GNUNET_strdup (data);
+  jwt_string = GNUNET_strndup (data, data_size);
   const char *jwt_body = strtok (jwt_string, delim);
   jwt_body = strtok (NULL, delim);
   GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body),
@@ -212,7 +213,7 @@ struct GNUNET_RECLAIM_AttributeList *
 jwt_parse_attributes_c (void *cls,
                         const struct GNUNET_RECLAIM_Credential *cred)
 {
-  return jwt_parse_attributes (cls, cred->data);
+  return jwt_parse_attributes (cls, cred->data, cred->data_size);
 }
 
 
@@ -227,7 +228,7 @@ struct GNUNET_RECLAIM_AttributeList *
 jwt_parse_attributes_p (void *cls,
                         const struct GNUNET_RECLAIM_Presentation *cred)
 {
-  return jwt_parse_attributes (cls, cred->data);
+  return jwt_parse_attributes (cls, cred->data, cred->data_size);
 }
 
 
@@ -240,7 +241,8 @@ jwt_parse_attributes_p (void *cls,
  */
 char *
 jwt_get_issuer (void *cls,
-                const char *data)
+                const char *data,
+                size_t data_size)
 {
   const char *jwt_body;
   char *jwt_string;
@@ -252,7 +254,7 @@ jwt_get_issuer (void *cls,
   json_t *json_val;
   json_error_t *json_err = NULL;
 
-  jwt_string = GNUNET_strdup (data);
+  jwt_string = GNUNET_strndup (data, data_size);
   jwt_body = strtok (jwt_string, delim);
   jwt_body = strtok (NULL, delim);
   GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body),
@@ -280,7 +282,7 @@ jwt_get_issuer_c (void *cls,
 {
   if (GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT != cred->type)
     return NULL;
-  return jwt_get_issuer (cls, cred->data);
+  return jwt_get_issuer (cls, cred->data, cred->data_size);
 }
 
 
@@ -297,7 +299,7 @@ jwt_get_issuer_p (void *cls,
 {
   if (GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT != cred->type)
     return NULL;
-  return jwt_get_issuer (cls, cred->data);
+  return jwt_get_issuer (cls, cred->data, cred->data_size);
 }
 
 
@@ -311,6 +313,7 @@ jwt_get_issuer_p (void *cls,
 int
 jwt_get_expiration (void *cls,
                     const char *data,
+                    size_t data_size,
                     struct GNUNET_TIME_Absolute *exp)
 {
   const char *jwt_body;
@@ -322,7 +325,7 @@ jwt_get_expiration (void *cls,
   json_t *json_val;
   json_error_t *json_err = NULL;
 
-  jwt_string = GNUNET_strdup (data);
+  jwt_string = GNUNET_strndup (data, data_size);
   jwt_body = strtok (jwt_string, delim);
   jwt_body = strtok (NULL, delim);
   GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body),
@@ -349,7 +352,7 @@ jwt_get_expiration_c (void *cls,
                       const struct GNUNET_RECLAIM_Credential *cred,
                       struct GNUNET_TIME_Absolute *exp)
 {
-  return jwt_get_expiration (cls, cred->data, exp);
+  return jwt_get_expiration (cls, cred->data, cred->data_size, exp);
 }
 
 
@@ -365,7 +368,7 @@ jwt_get_expiration_p (void *cls,
                       const struct GNUNET_RECLAIM_Presentation *cred,
                       struct GNUNET_TIME_Absolute *exp)
 {
-  return jwt_get_expiration (cls, cred->data, exp);
+  return jwt_get_expiration (cls, cred->data, cred->data_size, exp);
 }
 
 
diff --git a/src/reclaim/reclaim_credential.c b/src/reclaim/reclaim_credential.c
index 5c8974400..b85ba5955 100644
--- a/src/reclaim/reclaim_credential.c
+++ b/src/reclaim/reclaim_credential.c
@@ -721,7 +721,6 @@ GNUNET_RECLAIM_presentation_list_serialize_get_size (
   {
     GNUNET_assert (NULL != le->presentation);
     len += GNUNET_RECLAIM_presentation_serialize_get_size (le->presentation);
-    len += sizeof(struct GNUNET_RECLAIM_PresentationListEntry);
   }
   return len;
 }
@@ -774,8 +773,7 @@ GNUNET_RECLAIM_presentation_list_deserialize (const char 
*data, size_t
 
   al = GNUNET_new (struct GNUNET_RECLAIM_PresentationList);
 
-  if ((data_size < sizeof(struct Presentation)
-       + sizeof(struct GNUNET_RECLAIM_PresentationListEntry)))
+  if (data_size < sizeof(struct Presentation))
     return al;
 
   read_ptr = data;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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