summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-09-16 09:11:44 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-09-16 09:11:44 +0800
commitdff3a77d3179f178f06f12e477a3d5815b8f219f (patch)
tree262d2aaf613585b2c42725baf8539f39561932cc
parent8ae4a0aa882abd9911709012bfbe86015ac820fd (diff)
Shop & HMAC retrieval lines made fewer
-rw-r--r--shopify.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/shopify.c b/shopify.c
index 2bc239c..773172f 100644
--- a/shopify.c
+++ b/shopify.c
@@ -107,17 +107,16 @@ bool shopify_valid(struct MHD_Connection *conn, const char *url,
if (!nparams)
return false;
qsort(*params, nparams, sizeof(struct shopify_param), keycmp);
+ struct shopify_param *param = NULL;
char *shop = NULL;
- struct shopify_param *param = bsearch(&(struct shopify_param)
- { "shop" }, *params, nparams,
- sizeof(struct shopify_param), keycmp);
- if (param)
+ if ((param = bsearch(&(struct shopify_param) { "shop" }, *params,
+ nparams, sizeof(struct shopify_param),
+ keycmp)))
shop = param->val;
if (!shop || !regex_match(shop)) {
clear(*params);
return false;
}
- param = NULL;
char *query = NULL;
for (int i = 0; i < nparams; i++) {
const char *key = (*params)[i].key;
@@ -134,9 +133,9 @@ bool shopify_valid(struct MHD_Connection *conn, const char *url,
}
}
char *hmac = NULL;
- param = bsearch(&(struct shopify_param){ "hmac" }, *params, nparams,
- sizeof(struct shopify_param), keycmp);
- if (param)
+ if ((param = bsearch(&(struct shopify_param) { "hmac" }, *params,
+ nparams, sizeof(struct shopify_param),
+ keycmp)))
hmac = param->val;
if (!hmac || !crypt_maccmp(secret_key, query, hmac)) {
clear(*params);