commit afb5ccc6eb21fe92c788e38ff738195dc4c4ef91
parent b7e13a3a747653d68e74b824291968d66ccf0a78
Author: Florian Dold <dold@inria.fr>
Date: Sun, 20 Dec 2015 13:28:00 +0100
Send clearer error, avoid use-after-free.
Diffstat:
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c
@@ -543,11 +543,12 @@ process_pay_with_mint (void *cls,
dc);
if (NULL == dc->dh)
{
+ /* Signature was invalid. If the mint was unavailable,
+ * we'd get that information in the callback. */
resume_pay_with_response (pc,
- MHD_HTTP_SERVICE_UNAVAILABLE,
- TMH_RESPONSE_make_json_pack ("{s:s, s:i}",
- "mint", pc->chosen_mint,
- "transaction_id", pc->transaction_id));
+ MHD_HTTP_UNAUTHORIZED,
+ TMH_RESPONSE_make_json_pack ("{s:s}",
+ "hint", "Coin signature invalid."));
return;
}
}
@@ -577,6 +578,8 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
int res;
json_t *root;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "In handler for /pay.\n");
+
if (NULL == *connection_cls)
{
pc = GNUNET_new (struct PayContext);
@@ -594,6 +597,7 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
/* We are *done* processing the request, just queue the response (!) */
if (UINT_MAX == pc->response_code)
return MHD_NO; /* hard error */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Queueing response for /pay.\n");
res = MHD_queue_response (connection,
pc->response_code,
pc->response);
@@ -635,12 +639,15 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
res = TMH_PARSE_json_data (connection,
root,
spec);
+
if (GNUNET_YES != res)
{
json_decref (root);
return (GNUNET_NO == res) ? MHD_YES : MHD_NO;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Parsed JSON for /pay.\n");
+
/* 'edate' is optional, if it is not present, generate it here; it
will be timestamp plus the edate_delay supplied in config
file */
@@ -703,6 +710,8 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
}
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking up chosen mint '%s'\n", pc->chosen_mint);
+
/* Find the responsible mint, this may take a while... */
pc->pending = pc->coins_cnt;
pc->fo = TMH_MINTS_find_mint (pc->chosen_mint,