From dbffac740680e26e6a310ec7100e6bc0ae45af61 Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Thu, 31 Jan 2019 15:13:43 +0100 Subject: Proposal logic. Checking if the instance(s) given by the frontend when it creates the proposal are the same. --- src/backend/taler-merchant-httpd.c | 4 +++- src/backend/taler-merchant-httpd_proposal.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c index 44937fdc..1eb39261 100644 --- a/src/backend/taler-merchant-httpd.c +++ b/src/backend/taler-merchant-httpd.c @@ -1052,7 +1052,9 @@ TMH_lookup_instance (const char *name) /** - * Extract merchant instance from the given JSON + * Extract merchant instance from the given JSON; if not + * 'instance' field was found, then "default" instance is + * returned. * * @param json the JSON to inspect; it is not required to * comply with any particular format. It will only be checked diff --git a/src/backend/taler-merchant-httpd_proposal.c b/src/backend/taler-merchant-httpd_proposal.c index 0ce99287..b2dc610f 100644 --- a/src/backend/taler-merchant-httpd_proposal.c +++ b/src/backend/taler-merchant-httpd_proposal.c @@ -447,6 +447,20 @@ proposal_put (struct MHD_Connection *connection, } mi = TMH_lookup_instance_json (merchant); + + /* The outer instance field, and the one included + * in the merchant object are different */ + if (0 != strcmp (mi->id, + instance)) + { + TALER_LOG_ERROR + ("Inconsistent instance specified by merchant\n"); + return TMH_RESPONSE_reply_not_found + (connection, + TALER_EC_CONTRACT_INSTANCE_INCONSISTENT, + "Inconsistent instance given"); + } + if (NULL == mi) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, -- cgit v1.2.3