From 63137dc40490433b51fb6ee860f23d9a1ca41559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Thu, 22 Sep 2022 13:26:16 +0800 Subject: Merge base64.h to shopify.c cause it's too small --- shopify.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'shopify.c') diff --git a/shopify.c b/shopify.c index 8df5314..fe7f52b 100644 --- a/shopify.c +++ b/shopify.c @@ -1,10 +1,10 @@ #include #include #include +#include #include #include "shopify.h" #include "crypt.h" -#include "base64.h" #include "regex.h" #include "config.h" #include "request.h" @@ -47,7 +47,6 @@ extern inline void crypt_init(); extern inline bool crypt_macmatch(const char *, const char *, const char *); extern inline void crypt_getnonce(char [], const size_t); extern inline bool regex_match(const char *); -extern inline void base64_getdecoded(const char *, char **); extern inline void config_getscopes(const char *, char **); extern inline void request_init(); extern inline void request_gettoken(const char *, const char *, const char *, @@ -311,6 +310,7 @@ static enum MHD_Result handle_request(void *cls, struct MHD_Connection *con, return MHD_NO; } } + char *host = NULL; size_t host_len = 0; bool embedded = false; @@ -323,8 +323,17 @@ static enum MHD_Result handle_request(void *cls, struct MHD_Connection *con, param = bsearch(&(struct parameter){ "embedded" }, params, nparams, sizeof(struct parameter), keycmp); embedded = param && !strcmp(param->val, "1"); - base64_getdecoded(host, &dec_host); + + gnutls_datum_t result; + gnutls_base64_decode2(&(gnutls_datum_t){ + (unsigned char *)host, + strlen(host) + }, &result); + *dec_host = malloc(result.size + 1); + strlcpy(*dec_host, (const char *)result.data, result.size + 1); + gnutls_free(result.data); } + const char *app_id = container->app_id; char header[EMBEDDED_HEADER_LEN + shop_len + 1]; sprintf(header, EMBEDDED_HEADER, shop); -- cgit v1.2.3