commit 401f762a4a54968350cb9769f3fbf3976b7ca65f
parent 2615be3e2d944462cf6e0142a3e9ef73879db479
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 31 May 2026 00:36:50 +0200
-misc bugfixes
Diffstat:
5 files changed, 35 insertions(+), 26 deletions(-)
diff --git a/src/backend/paivana-httpd_cookie.c b/src/backend/paivana-httpd_cookie.c
@@ -74,8 +74,8 @@ compute_cookie_hash (struct GNUNET_TIME_Timestamp cur_time,
sizeof (e),
&paivana_secret, /* source key material */
sizeof (paivana_secret),
- GNUNET_CRYPTO_kdf_arg (website,
- strlen (website) + 1),
+ GNUNET_CRYPTO_kdf_arg (website,
+ strlen (website) + 1),
GNUNET_CRYPTO_kdf_arg (ca,
ca_len)));
}
@@ -154,19 +154,20 @@ PAIVANA_HTTPD_compute_cookie (struct GNUNET_TIME_Timestamp cur_time,
char cstr[128];
char *res;
const char *url = "/";
- bool use_https = strncasecmp (website,
- "https://",
- strlen ("https://"));
+ bool use_https = (0 ==
+ strncasecmp (website,
+ "https://",
+ strlen ("https://")));
struct GNUNET_TIME_Relative duration
= GNUNET_TIME_absolute_get_remaining (cur_time.abs_time);
- if (! PH_global_cookie)
+ if (! PH_global_cookie)
{
const char *dslash = strstr (website,
- "//");
+ "//");
if (NULL != dslash)
url = strchr (dslash + 2,
- '/');
+ '/');
}
compute_cookie_hash (cur_time,
website,
diff --git a/src/backend/paivana-httpd_daemon.c b/src/backend/paivana-httpd_daemon.c
@@ -144,11 +144,13 @@ create_response (void *cls,
if (PH_have_whitelist_ex && (! rc->do_forward))
{
rc->do_forward = (0 ==
- regcomp (&PH_whitelist_ex,
- url,
- REG_NOSUB | REG_EXTENDED));
+ regexec (&PH_whitelist_ex,
+ url,
+ 0,
+ NULL,
+ 0));
}
-
+
if (rc->do_forward)
goto do_forward;
@@ -182,8 +184,8 @@ create_response (void *cls,
"Paivana-Cookie");
if (NULL != cookie)
{
- void *ca;
- size_t ca_len;
+ void *ca = NULL;
+ size_t ca_len = 0;
GNUNET_break (PAIVANA_HTTPD_get_client_address (con,
&ca,
diff --git a/src/backend/paivana-httpd_pay.c b/src/backend/paivana-httpd_pay.c
@@ -235,8 +235,8 @@ order_status_cb (struct PayRequest *ph,
}
else
{
- void *ca;
- size_t ca_len;
+ void *ca = NULL;
+ size_t ca_len = 0;
char *cookie;
struct MHD_Response *resp;
@@ -247,7 +247,7 @@ order_status_cb (struct PayRequest *ph,
&ca,
&ca_len));
cookie = PAIVANA_HTTPD_compute_cookie (ph->cur_time,
- ph->website,
+ ph->website,
ca_len,
ca);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
diff --git a/src/backend/paivana-httpd_reverse.c b/src/backend/paivana-httpd_reverse.c
@@ -808,6 +808,8 @@ build_host_header (const char *url)
hostname = strstr (dup,
MARKER);
+ if (NULL == hostname)
+ return NULL;
hostname += 3;
end = strchrnul (hostname, '/');
*end = '\0';
@@ -1387,11 +1389,14 @@ start_curl_request (struct HttpRequest *hr,
char *host_hdr;
host_hdr = build_host_header (PH_target_server_base_url);
- PAIVANA_LOG_DEBUG ("Faking the host header, %s\n",
- host_hdr);
- hr->headers = curl_slist_append (hr->headers,
- host_hdr);
- GNUNET_free (host_hdr);
+ if (NULL != host_hdr)
+ {
+ PAIVANA_LOG_DEBUG ("Faking the host header, %s\n",
+ host_hdr);
+ hr->headers = curl_slist_append (hr->headers,
+ host_hdr);
+ GNUNET_free (host_hdr);
+ }
}
r = configure_curl_method (hr,
diff --git a/src/backend/paivana-httpd_templates.c b/src/backend/paivana-httpd_templates.c
@@ -289,10 +289,11 @@ load_paywall (struct MHD_Connection *conn,
t->choices),
GNUNET_JSON_pack_bool (
"has_choices",
- 1 < json_array_size(t->choices)),
- GNUNET_JSON_pack_object_steal (
- "default_choice",
- json_array_get(t->choices, 0)),
+ 1 < json_array_size (t->choices)),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_object_steal (
+ "default_choice",
+ json_array_get (t->choices, 0))),
GNUNET_JSON_pack_uint64 (
"max_pickup_delay",
t->max_pickup_delay.rel_value_us / 1000LLU / 1000LLU),