aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/plugin_reclaim_credential_jwt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/reclaim/plugin_reclaim_credential_jwt.c')
-rw-r--r--src/reclaim/plugin_reclaim_credential_jwt.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/reclaim/plugin_reclaim_credential_jwt.c b/src/reclaim/plugin_reclaim_credential_jwt.c
index f30ead570..c1e12f4a0 100644
--- a/src/reclaim/plugin_reclaim_credential_jwt.c
+++ b/src/reclaim/plugin_reclaim_credential_jwt.c
@@ -173,6 +173,7 @@ jwt_parse_attributes (void *cls,
173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Decoded JWT: %s\n", decoded_jwt); 173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Decoded JWT: %s\n", decoded_jwt);
174 GNUNET_assert (NULL != decoded_jwt); 174 GNUNET_assert (NULL != decoded_jwt);
175 json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err); 175 json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err);
176 GNUNET_free (decoded_jwt);
176 const char *key; 177 const char *key;
177 json_t *value; 178 json_t *value;
178 json_object_foreach (json_val, key, value) { 179 json_object_foreach (json_val, key, value) {
@@ -197,6 +198,7 @@ jwt_parse_attributes (void *cls,
197 strlen (val_str)); 198 strlen (val_str));
198 GNUNET_free (val_str); 199 GNUNET_free (val_str);
199 } 200 }
201 json_decref (json_val);
200 GNUNET_free (jwt_string); 202 GNUNET_free (jwt_string);
201 return attrs; 203 return attrs;
202} 204}
@@ -260,11 +262,17 @@ jwt_get_issuer (void *cls,
260 GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), 262 GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body),
261 (void **) &decoded_jwt); 263 (void **) &decoded_jwt);
262 json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err); 264 json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err);
265 GNUNET_free (decoded_jwt);
266 GNUNET_free (jwt_string);
267 if (NULL == json_val)
268 return NULL;
263 issuer_json = json_object_get (json_val, "iss"); 269 issuer_json = json_object_get (json_val, "iss");
264 if ((NULL == issuer_json) || (! json_is_string (issuer_json))) 270 if ((NULL == issuer_json) || (! json_is_string (issuer_json))) {
271 json_decref (json_val);
265 return NULL; 272 return NULL;
273 }
266 issuer = GNUNET_strdup (json_string_value (issuer_json)); 274 issuer = GNUNET_strdup (json_string_value (issuer_json));
267 GNUNET_free (jwt_string); 275 json_decref (json_val);
268 return issuer; 276 return issuer;
269} 277}
270 278
@@ -331,11 +339,17 @@ jwt_get_expiration (void *cls,
331 GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), 339 GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body),
332 (void **) &decoded_jwt); 340 (void **) &decoded_jwt);
333 json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err); 341 json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err);
342 GNUNET_free (decoded_jwt);
343 GNUNET_free (jwt_string);
344 if (NULL == json_val)
345 return GNUNET_SYSERR;
334 exp_json = json_object_get (json_val, "exp"); 346 exp_json = json_object_get (json_val, "exp");
335 if ((NULL == exp_json) || (! json_is_integer (exp_json))) 347 if ((NULL == exp_json) || (! json_is_integer (exp_json))) {
348 json_decref (json_val);
336 return GNUNET_SYSERR; 349 return GNUNET_SYSERR;
350 }
337 exp->abs_value_us = json_integer_value (exp_json) * 1000 * 1000; 351 exp->abs_value_us = json_integer_value (exp_json) * 1000 * 1000;
338 GNUNET_free (jwt_string); 352 json_decref (json_val);
339 return GNUNET_OK; 353 return GNUNET_OK;
340} 354}
341 355