diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2021-04-21 12:26:34 +0200 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2021-04-21 12:26:34 +0200 |
commit | 6c1b06b0629b146981fcdfb5ecea40bbc6450a9e (patch) | |
tree | e8131f10c208a44eefd7a84a3e6e9c77879ffa2d /src/reclaim/plugin_reclaim_credential_pabc.c | |
parent | 316a9ea66e029fc0ced2c76de42ba044d377ccec (diff) | |
download | gnunet-6c1b06b0629b146981fcdfb5ecea40bbc6450a9e.tar.gz gnunet-6c1b06b0629b146981fcdfb5ecea40bbc6450a9e.zip |
-fix expiration
Diffstat (limited to 'src/reclaim/plugin_reclaim_credential_pabc.c')
-rw-r--r-- | src/reclaim/plugin_reclaim_credential_pabc.c | 51 |
1 files changed, 18 insertions, 33 deletions
diff --git a/src/reclaim/plugin_reclaim_credential_pabc.c b/src/reclaim/plugin_reclaim_credential_pabc.c index c993ba485..ff04624a4 100644 --- a/src/reclaim/plugin_reclaim_credential_pabc.c +++ b/src/reclaim/plugin_reclaim_credential_pabc.c | |||
@@ -146,8 +146,8 @@ pabc_number_to_typename (void *cls, uint32_t type) | |||
146 | 146 | ||
147 | static void | 147 | static void |
148 | inspect_attrs (char const *const key, | 148 | inspect_attrs (char const *const key, |
149 | char const *const value, | 149 | char const *const value, |
150 | void *ctx) | 150 | void *ctx) |
151 | { | 151 | { |
152 | struct GNUNET_RECLAIM_AttributeList *attrs = ctx; | 152 | struct GNUNET_RECLAIM_AttributeList *attrs = ctx; |
153 | 153 | ||
@@ -228,6 +228,7 @@ pabc_parse_attributes_p (void *cls, | |||
228 | return pabc_parse_attributes (cls, cred->data, cred->data_size); | 228 | return pabc_parse_attributes (cls, cred->data, cred->data_size); |
229 | } | 229 | } |
230 | 230 | ||
231 | |||
231 | /** | 232 | /** |
232 | * Parse a pabc and return the issuer | 233 | * Parse a pabc and return the issuer |
233 | * | 234 | * |
@@ -296,43 +297,27 @@ pabc_get_expiration (void *cls, | |||
296 | size_t data_size, | 297 | size_t data_size, |
297 | struct GNUNET_TIME_Absolute *exp) | 298 | struct GNUNET_TIME_Absolute *exp) |
298 | { | 299 | { |
299 | json_t *json_root; | 300 | uint32_t exp_i; |
300 | json_t *json_attrs; | 301 | char *exp_str; |
301 | json_t *value; | 302 | |
302 | json_t *exp_j; | 303 | if (PABC_OK != pabc_cred_get_attr_by_name_from_cred (data, |
303 | json_error_t *json_err = NULL; | 304 | "expiration", |
304 | 305 | &exp_str)) | |
305 | json_root = json_loads (data, JSON_DECODE_ANY, json_err); | ||
306 | if ((NULL == json_root) || | ||
307 | (! json_is_object (json_root))) | ||
308 | { | 306 | { |
309 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 307 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
310 | "%s is not a valid pabc credentials (not an object)\n", | 308 | "Unable to retrive expiration from credential\n"); |
311 | data); | ||
312 | if (NULL != json_root) | ||
313 | json_decref (json_root); | ||
314 | return GNUNET_SYSERR; | 309 | return GNUNET_SYSERR; |
315 | } | 310 | } |
316 | json_attrs = json_object_get (json_root, PABC_JSON_PLAIN_ATTRS_KEY); | 311 | |
317 | if ((NULL == json_attrs) || | 312 | if (1 != sscanf (exp_str, "%u", &exp_i)) |
318 | (! json_is_object (json_attrs))) | ||
319 | { | 313 | { |
320 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 314 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
321 | "%s is not a valid pabc credential (attributes not an object)\n", | 315 | "Invalid expiration `%s'\n", exp_str); |
322 | data); | 316 | GNUNET_free (exp_str); |
323 | json_decref (json_root); | ||
324 | return GNUNET_SYSERR; | 317 | return GNUNET_SYSERR; |
325 | } | 318 | } |
326 | exp_j = json_object_get (json_attrs, "expiration"); | 319 | exp->abs_value_us = exp_i * 1000 * 1000; |
327 | if ((NULL != exp_j) && | 320 | return GNUNET_OK; |
328 | json_is_integer (exp_j)) | ||
329 | { | ||
330 | exp->abs_value_us = json_integer_value (value) * 1000 * 1000; | ||
331 | json_decref (json_root); | ||
332 | return GNUNET_OK; | ||
333 | } | ||
334 | json_decref (json_root); | ||
335 | return GNUNET_SYSERR; | ||
336 | } | 321 | } |
337 | 322 | ||
338 | 323 | ||
@@ -418,8 +403,8 @@ pabc_create_presentation (void *cls, | |||
418 | return GNUNET_SYSERR; | 403 | return GNUNET_SYSERR; |
419 | } | 404 | } |
420 | if (PABC_OK != pabc_cred_get_attr_by_name_from_cred (credential->data, | 405 | if (PABC_OK != pabc_cred_get_attr_by_name_from_cred (credential->data, |
421 | "subject", | 406 | "subject", |
422 | &subject)) | 407 | &subject)) |
423 | { | 408 | { |
424 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 409 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
425 | "Failed to get subject.\n"); | 410 | "Failed to get subject.\n"); |