summaryrefslogtreecommitdiff
path: root/src/kyclogic
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-06-04 13:26:00 +0200
committerChristian Grothoff <christian@grothoff.org>2023-06-04 13:26:00 +0200
commit809300158caaa0215c36ef89c7e38f0edfa93593 (patch)
tree1faf7e314af34db7a2333d8003ee0ed6fca91d74 /src/kyclogic
parent9718bc4920ab4781378b777bf3e2af275c8d0575 (diff)
downloadexchange-809300158caaa0215c36ef89c7e38f0edfa93593.tar.gz
exchange-809300158caaa0215c36ef89c7e38f0edfa93593.tar.bz2
exchange-809300158caaa0215c36ef89c7e38f0edfa93593.zip
code cleanup, fixing misc. memory leaks in the process
Diffstat (limited to 'src/kyclogic')
-rw-r--r--src/kyclogic/plugin_kyclogic_kycaid.c18
-rw-r--r--src/kyclogic/plugin_kyclogic_oauth2.c9
-rw-r--r--src/kyclogic/plugin_kyclogic_persona.c45
3 files changed, 22 insertions, 50 deletions
diff --git a/src/kyclogic/plugin_kyclogic_kycaid.c b/src/kyclogic/plugin_kyclogic_kycaid.c
index 95dc4bb78..058c41e17 100644
--- a/src/kyclogic/plugin_kyclogic_kycaid.c
+++ b/src/kyclogic/plugin_kyclogic_kycaid.c
@@ -758,11 +758,12 @@ kycaid_webhook_cancel (struct TALER_KYCLOGIC_WebhookHandle *wh)
* @param verifications JSON object with failure details
*/
static void
-log_failure (json_t *verifications)
+log_failure (const json_t *verifications)
{
- json_t *member;
+ const json_t *member;
const char *name;
- json_object_foreach (verifications, name, member)
+
+ json_object_foreach ((json_t *) verifications, name, member)
{
bool iverified;
const char *comment;
@@ -1176,7 +1177,7 @@ kycaid_webhook (void *cls,
const char *status = NULL;
bool verified = false;
bool no_verified = true;
- json_t *verifications = NULL;
+ const json_t *verifications = NULL;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("request_id",
&request_id),
@@ -1195,8 +1196,8 @@ kycaid_webhook (void *cls,
&verified),
&no_verified),
GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_json ("verifications",
- &verifications),
+ GNUNET_JSON_spec_object_const ("verifications",
+ &verifications),
NULL),
GNUNET_JSON_spec_end ()
};
@@ -1253,7 +1254,6 @@ kycaid_webhook (void *cls,
wh->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
wh->task = GNUNET_SCHEDULER_add_now (&async_webhook_reply,
wh);
- GNUNET_JSON_parse_free (spec);
return wh;
}
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
@@ -1267,7 +1267,6 @@ kycaid_webhook (void *cls,
wh->response_code = MHD_HTTP_NOT_FOUND;
wh->task = GNUNET_SCHEDULER_add_now (&async_webhook_reply,
wh);
- GNUNET_JSON_parse_free (spec);
return wh;
}
wh->verification_id = GNUNET_strdup (verification_id);
@@ -1286,7 +1285,6 @@ kycaid_webhook (void *cls,
MHD_RESPMEM_PERSISTENT);
wh->task = GNUNET_SCHEDULER_add_now (&async_webhook_reply,
wh);
- GNUNET_JSON_parse_free (spec);
return wh;
}
@@ -1300,7 +1298,6 @@ kycaid_webhook (void *cls,
wh->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
wh->task = GNUNET_SCHEDULER_add_now (&async_webhook_reply,
wh);
- GNUNET_JSON_parse_free (spec);
return wh;
}
@@ -1324,7 +1321,6 @@ kycaid_webhook (void *cls,
pd->slist,
&handle_webhook_finished,
wh);
- GNUNET_JSON_parse_free (spec);
return wh;
}
diff --git a/src/kyclogic/plugin_kyclogic_oauth2.c b/src/kyclogic/plugin_kyclogic_oauth2.c
index e7350f01c..c9e5d8dcf 100644
--- a/src/kyclogic/plugin_kyclogic_oauth2.c
+++ b/src/kyclogic/plugin_kyclogic_oauth2.c
@@ -951,12 +951,12 @@ parse_proof_success_reply (struct TALER_KYCLOGIC_ProofHandle *ph,
const json_t *j)
{
const char *state;
- json_t *data;
+ const json_t *data;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("status",
&state),
- GNUNET_JSON_spec_json ("data",
- &data),
+ GNUNET_JSON_spec_object_const ("data",
+ &data),
GNUNET_JSON_spec_end ()
};
enum GNUNET_GenericReturnValue res;
@@ -988,7 +988,6 @@ parse_proof_success_reply (struct TALER_KYCLOGIC_ProofHandle *ph,
GNUNET_break_op (0);
handle_proof_error (ph,
j);
- GNUNET_JSON_parse_free (spec);
return;
}
{
@@ -1016,7 +1015,6 @@ parse_proof_success_reply (struct TALER_KYCLOGIC_ProofHandle *ph,
"Unexpected response from KYC gateway: data must contain id");
ph->http_status
= MHD_HTTP_BAD_GATEWAY;
- GNUNET_JSON_parse_free (spec);
return;
}
ph->status = TALER_KYCLOGIC_STATUS_SUCCESS;
@@ -1034,7 +1032,6 @@ parse_proof_success_reply (struct TALER_KYCLOGIC_ProofHandle *ph,
}
ph->attributes = data2attributes (ph->pd,
data);
- GNUNET_JSON_parse_free (spec);
}
diff --git a/src/kyclogic/plugin_kyclogic_persona.c b/src/kyclogic/plugin_kyclogic_persona.c
index e14a50390..406307838 100644
--- a/src/kyclogic/plugin_kyclogic_persona.c
+++ b/src/kyclogic/plugin_kyclogic_persona.c
@@ -1113,17 +1113,17 @@ handle_proof_finished (void *cls,
const char *inquiry_id;
const char *account_id;
const char *type = NULL;
- json_t *attributes;
- json_t *relationships;
+ const json_t *attributes;
+ const json_t *relationships;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("type",
&type),
GNUNET_JSON_spec_string ("id",
&inquiry_id),
- GNUNET_JSON_spec_json ("attributes",
- &attributes),
- GNUNET_JSON_spec_json ("relationships",
- &relationships),
+ GNUNET_JSON_spec_object_const ("attributes",
+ &attributes),
+ GNUNET_JSON_spec_object_const ("relationships",
+ &relationships),
GNUNET_JSON_spec_end ()
};
@@ -1141,7 +1141,6 @@ handle_proof_finished (void *cls,
inquiry_id,
"data",
data);
- GNUNET_JSON_parse_free (spec);
break;
}
@@ -1172,8 +1171,6 @@ handle_proof_finished (void *cls,
inquiry_id,
"data-attributes",
data);
- GNUNET_JSON_parse_free (ispec);
- GNUNET_JSON_parse_free (spec);
break;
}
{
@@ -1192,8 +1189,6 @@ handle_proof_finished (void *cls,
inquiry_id,
"data-attributes-reference_id",
data);
- GNUNET_JSON_parse_free (ispec);
- GNUNET_JSON_parse_free (spec);
break;
}
}
@@ -1207,8 +1202,6 @@ handle_proof_finished (void *cls,
inquiry_id,
"data-id",
data);
- GNUNET_JSON_parse_free (ispec);
- GNUNET_JSON_parse_free (spec);
break;
}
@@ -1240,8 +1233,6 @@ handle_proof_finished (void *cls,
GNUNET_JSON_pack_object_incref ("data",
(json_t *)
data))));
- GNUNET_JSON_parse_free (ispec);
- GNUNET_JSON_parse_free (spec);
break;
}
@@ -1260,9 +1251,7 @@ handle_proof_finished (void *cls,
j,
&proof_post_conversion_cb,
ph);
- GNUNET_JSON_parse_free (ispec);
}
- GNUNET_JSON_parse_free (spec);
return; /* continued in proof_post_conversion_cb */
}
case MHD_HTTP_BAD_REQUEST:
@@ -1649,17 +1638,17 @@ handle_webhook_finished (void *cls,
const char *inquiry_id;
const char *account_id;
const char *type = NULL;
- json_t *attributes;
- json_t *relationships;
+ const json_t *attributes;
+ const json_t *relationships;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("type",
&type),
GNUNET_JSON_spec_string ("id",
&inquiry_id),
- GNUNET_JSON_spec_json ("attributes",
- &attributes),
- GNUNET_JSON_spec_json ("relationships",
- &relationships),
+ GNUNET_JSON_spec_object_const ("attributes",
+ &attributes),
+ GNUNET_JSON_spec_object_const ("relationships",
+ &relationships),
GNUNET_JSON_spec_end ()
};
@@ -1709,8 +1698,6 @@ handle_webhook_finished (void *cls,
webhook_reply_error (wh,
inquiry_id,
MHD_HTTP_BAD_GATEWAY);
- GNUNET_JSON_parse_free (ispec);
- GNUNET_JSON_parse_free (spec);
break;
}
{
@@ -1727,8 +1714,6 @@ handle_webhook_finished (void *cls,
webhook_reply_error (wh,
inquiry_id,
MHD_HTTP_BAD_GATEWAY);
- GNUNET_JSON_parse_free (ispec);
- GNUNET_JSON_parse_free (spec);
break;
}
}
@@ -1740,8 +1725,6 @@ handle_webhook_finished (void *cls,
webhook_reply_error (wh,
inquiry_id,
MHD_HTTP_BAD_GATEWAY);
- GNUNET_JSON_parse_free (ispec);
- GNUNET_JSON_parse_free (spec);
break;
}
@@ -1763,8 +1746,6 @@ handle_webhook_finished (void *cls,
inquiry_id,
NULL,
MHD_HTTP_OK);
- GNUNET_JSON_parse_free (ispec);
- GNUNET_JSON_parse_free (spec);
break;
}
@@ -1784,9 +1765,7 @@ handle_webhook_finished (void *cls,
j,
&webhook_post_conversion_cb,
wh);
- GNUNET_JSON_parse_free (ispec);
}
- GNUNET_JSON_parse_free (spec);
return; /* continued in webhook_post_conversion_cb */
}
case MHD_HTTP_BAD_REQUEST: