diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2020-12-25 21:37:28 +0900 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2020-12-25 21:37:28 +0900 |
commit | 1e37e8edc0c23674df6c2144e3f2d83e3dbc1bc2 (patch) | |
tree | 52c42a8155537045c1c7557bf13853b711a1cb64 /src/reclaim | |
parent | debba1a49a46ba963553da222ade563d6d67932b (diff) | |
download | gnunet-1e37e8edc0c23674df6c2144e3f2d83e3dbc1bc2.tar.gz gnunet-1e37e8edc0c23674df6c2144e3f2d83e3dbc1bc2.zip |
fix error in presentation handling
Diffstat (limited to 'src/reclaim')
-rw-r--r-- | src/reclaim/gnunet-service-reclaim_tickets.c | 1 | ||||
-rw-r--r-- | src/reclaim/oidc_helper.c | 4 | ||||
-rw-r--r-- | src/reclaim/plugin_reclaim_attribute_basic.c | 2 | ||||
-rw-r--r-- | src/reclaim/plugin_reclaim_credential_jwt.c | 27 | ||||
-rw-r--r-- | 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, | |||
1542 | tih->presentations->list_tail, | 1542 | tih->presentations->list_tail, |
1543 | ple); | 1543 | ple); |
1544 | GNUNET_free (cred); | 1544 | GNUNET_free (cred); |
1545 | break; | ||
1545 | } | 1546 | } |
1546 | } | 1547 | } |
1547 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION == rd[i].record_type) | 1548 | 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, | |||
202 | GNUNET_asprintf (&source_name, | 202 | GNUNET_asprintf (&source_name, |
203 | "src%d", | 203 | "src%d", |
204 | i); | 204 | i); |
205 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
206 | "Adding new presentation source #%d\n", i); | ||
205 | aggr_sources_jwt = json_object (); | 207 | aggr_sources_jwt = json_object (); |
206 | pres_val_str = | 208 | pres_val_str = |
207 | GNUNET_RECLAIM_presentation_value_to_string (ple->presentation->type, | 209 | GNUNET_RECLAIM_presentation_value_to_string (ple->presentation->type, |
208 | ple->presentation->data, | 210 | ple->presentation->data, |
209 | ple->presentation->data_size); | 211 | ple->presentation->data_size); |
212 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
213 | "Presentation is: %s\n", pres_val_str); | ||
210 | json_object_set_new (aggr_sources_jwt, | 214 | json_object_set_new (aggr_sources_jwt, |
211 | GNUNET_RECLAIM_presentation_number_to_typename ( | 215 | GNUNET_RECLAIM_presentation_number_to_typename ( |
212 | ple->presentation->type), | 216 | 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, | |||
82 | { | 82 | { |
83 | case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING: | 83 | case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING: |
84 | *data = GNUNET_strdup (s); | 84 | *data = GNUNET_strdup (s); |
85 | *data_size = strlen (s); | 85 | *data_size = strlen (s) + 1; |
86 | return GNUNET_OK; | 86 | return GNUNET_OK; |
87 | 87 | ||
88 | default: | 88 | 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, | |||
81 | { | 81 | { |
82 | case GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT: | 82 | case GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT: |
83 | *data = GNUNET_strdup (s); | 83 | *data = GNUNET_strdup (s); |
84 | *data_size = strlen (s); | 84 | *data_size = strlen (s) + 1; |
85 | return GNUNET_OK; | 85 | return GNUNET_OK; |
86 | 86 | ||
87 | default: | 87 | default: |
@@ -151,7 +151,8 @@ jwt_number_to_typename (void *cls, uint32_t type) | |||
151 | */ | 151 | */ |
152 | struct GNUNET_RECLAIM_AttributeList * | 152 | struct GNUNET_RECLAIM_AttributeList * |
153 | jwt_parse_attributes (void *cls, | 153 | jwt_parse_attributes (void *cls, |
154 | const char *data) | 154 | const char *data, |
155 | size_t data_size) | ||
155 | { | 156 | { |
156 | char *jwt_string; | 157 | char *jwt_string; |
157 | struct GNUNET_RECLAIM_AttributeList *attrs; | 158 | struct GNUNET_RECLAIM_AttributeList *attrs; |
@@ -164,7 +165,7 @@ jwt_parse_attributes (void *cls, | |||
164 | 165 | ||
165 | attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); | 166 | attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); |
166 | 167 | ||
167 | jwt_string = GNUNET_strdup (data); | 168 | jwt_string = GNUNET_strndup (data, data_size); |
168 | const char *jwt_body = strtok (jwt_string, delim); | 169 | const char *jwt_body = strtok (jwt_string, delim); |
169 | jwt_body = strtok (NULL, delim); | 170 | jwt_body = strtok (NULL, delim); |
170 | GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), | 171 | GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), |
@@ -212,7 +213,7 @@ struct GNUNET_RECLAIM_AttributeList * | |||
212 | jwt_parse_attributes_c (void *cls, | 213 | jwt_parse_attributes_c (void *cls, |
213 | const struct GNUNET_RECLAIM_Credential *cred) | 214 | const struct GNUNET_RECLAIM_Credential *cred) |
214 | { | 215 | { |
215 | return jwt_parse_attributes (cls, cred->data); | 216 | return jwt_parse_attributes (cls, cred->data, cred->data_size); |
216 | } | 217 | } |
217 | 218 | ||
218 | 219 | ||
@@ -227,7 +228,7 @@ struct GNUNET_RECLAIM_AttributeList * | |||
227 | jwt_parse_attributes_p (void *cls, | 228 | jwt_parse_attributes_p (void *cls, |
228 | const struct GNUNET_RECLAIM_Presentation *cred) | 229 | const struct GNUNET_RECLAIM_Presentation *cred) |
229 | { | 230 | { |
230 | return jwt_parse_attributes (cls, cred->data); | 231 | return jwt_parse_attributes (cls, cred->data, cred->data_size); |
231 | } | 232 | } |
232 | 233 | ||
233 | 234 | ||
@@ -240,7 +241,8 @@ jwt_parse_attributes_p (void *cls, | |||
240 | */ | 241 | */ |
241 | char * | 242 | char * |
242 | jwt_get_issuer (void *cls, | 243 | jwt_get_issuer (void *cls, |
243 | const char *data) | 244 | const char *data, |
245 | size_t data_size) | ||
244 | { | 246 | { |
245 | const char *jwt_body; | 247 | const char *jwt_body; |
246 | char *jwt_string; | 248 | char *jwt_string; |
@@ -252,7 +254,7 @@ jwt_get_issuer (void *cls, | |||
252 | json_t *json_val; | 254 | json_t *json_val; |
253 | json_error_t *json_err = NULL; | 255 | json_error_t *json_err = NULL; |
254 | 256 | ||
255 | jwt_string = GNUNET_strdup (data); | 257 | jwt_string = GNUNET_strndup (data, data_size); |
256 | jwt_body = strtok (jwt_string, delim); | 258 | jwt_body = strtok (jwt_string, delim); |
257 | jwt_body = strtok (NULL, delim); | 259 | jwt_body = strtok (NULL, delim); |
258 | GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), | 260 | GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), |
@@ -280,7 +282,7 @@ jwt_get_issuer_c (void *cls, | |||
280 | { | 282 | { |
281 | if (GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT != cred->type) | 283 | if (GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT != cred->type) |
282 | return NULL; | 284 | return NULL; |
283 | return jwt_get_issuer (cls, cred->data); | 285 | return jwt_get_issuer (cls, cred->data, cred->data_size); |
284 | } | 286 | } |
285 | 287 | ||
286 | 288 | ||
@@ -297,7 +299,7 @@ jwt_get_issuer_p (void *cls, | |||
297 | { | 299 | { |
298 | if (GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT != cred->type) | 300 | if (GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT != cred->type) |
299 | return NULL; | 301 | return NULL; |
300 | return jwt_get_issuer (cls, cred->data); | 302 | return jwt_get_issuer (cls, cred->data, cred->data_size); |
301 | } | 303 | } |
302 | 304 | ||
303 | 305 | ||
@@ -311,6 +313,7 @@ jwt_get_issuer_p (void *cls, | |||
311 | int | 313 | int |
312 | jwt_get_expiration (void *cls, | 314 | jwt_get_expiration (void *cls, |
313 | const char *data, | 315 | const char *data, |
316 | size_t data_size, | ||
314 | struct GNUNET_TIME_Absolute *exp) | 317 | struct GNUNET_TIME_Absolute *exp) |
315 | { | 318 | { |
316 | const char *jwt_body; | 319 | const char *jwt_body; |
@@ -322,7 +325,7 @@ jwt_get_expiration (void *cls, | |||
322 | json_t *json_val; | 325 | json_t *json_val; |
323 | json_error_t *json_err = NULL; | 326 | json_error_t *json_err = NULL; |
324 | 327 | ||
325 | jwt_string = GNUNET_strdup (data); | 328 | jwt_string = GNUNET_strndup (data, data_size); |
326 | jwt_body = strtok (jwt_string, delim); | 329 | jwt_body = strtok (jwt_string, delim); |
327 | jwt_body = strtok (NULL, delim); | 330 | jwt_body = strtok (NULL, delim); |
328 | GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), | 331 | GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), |
@@ -349,7 +352,7 @@ jwt_get_expiration_c (void *cls, | |||
349 | const struct GNUNET_RECLAIM_Credential *cred, | 352 | const struct GNUNET_RECLAIM_Credential *cred, |
350 | struct GNUNET_TIME_Absolute *exp) | 353 | struct GNUNET_TIME_Absolute *exp) |
351 | { | 354 | { |
352 | return jwt_get_expiration (cls, cred->data, exp); | 355 | return jwt_get_expiration (cls, cred->data, cred->data_size, exp); |
353 | } | 356 | } |
354 | 357 | ||
355 | 358 | ||
@@ -365,7 +368,7 @@ jwt_get_expiration_p (void *cls, | |||
365 | const struct GNUNET_RECLAIM_Presentation *cred, | 368 | const struct GNUNET_RECLAIM_Presentation *cred, |
366 | struct GNUNET_TIME_Absolute *exp) | 369 | struct GNUNET_TIME_Absolute *exp) |
367 | { | 370 | { |
368 | return jwt_get_expiration (cls, cred->data, exp); | 371 | return jwt_get_expiration (cls, cred->data, cred->data_size, exp); |
369 | } | 372 | } |
370 | 373 | ||
371 | 374 | ||
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 ( | |||
721 | { | 721 | { |
722 | GNUNET_assert (NULL != le->presentation); | 722 | GNUNET_assert (NULL != le->presentation); |
723 | len += GNUNET_RECLAIM_presentation_serialize_get_size (le->presentation); | 723 | len += GNUNET_RECLAIM_presentation_serialize_get_size (le->presentation); |
724 | len += sizeof(struct GNUNET_RECLAIM_PresentationListEntry); | ||
725 | } | 724 | } |
726 | return len; | 725 | return len; |
727 | } | 726 | } |
@@ -774,8 +773,7 @@ GNUNET_RECLAIM_presentation_list_deserialize (const char *data, size_t | |||
774 | 773 | ||
775 | al = GNUNET_new (struct GNUNET_RECLAIM_PresentationList); | 774 | al = GNUNET_new (struct GNUNET_RECLAIM_PresentationList); |
776 | 775 | ||
777 | if ((data_size < sizeof(struct Presentation) | 776 | if (data_size < sizeof(struct Presentation)) |
778 | + sizeof(struct GNUNET_RECLAIM_PresentationListEntry))) | ||
779 | return al; | 777 | return al; |
780 | 778 | ||
781 | read_ptr = data; | 779 | read_ptr = data; |