summaryrefslogtreecommitdiff
path: root/src/backend/anastasis-httpd_policy.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-09-17 12:05:52 +0200
committerChristian Grothoff <christian@grothoff.org>2023-09-17 12:05:52 +0200
commit420434962743a3575ddac06b1c67e541e813cdf6 (patch)
treee913a1af4c225b2ea01be2fa66b30c9f7bab3a2d /src/backend/anastasis-httpd_policy.c
parentae9bf61430da8e6cc0e9b76e560c06c8302ffeb4 (diff)
downloadanastasis-420434962743a3575ddac06b1c67e541e813cdf6.tar.gz
anastasis-420434962743a3575ddac06b1c67e541e813cdf6.tar.bz2
anastasis-420434962743a3575ddac06b1c67e541e813cdf6.zip
use Etags in double-quotes as per standard, add missing 'return' in tests
Diffstat (limited to 'src/backend/anastasis-httpd_policy.c')
-rw-r--r--src/backend/anastasis-httpd_policy.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/backend/anastasis-httpd_policy.c b/src/backend/anastasis-httpd_policy.c
index a26d11e..177cc06 100644
--- a/src/backend/anastasis-httpd_policy.c
+++ b/src/backend/anastasis-httpd_policy.c
@@ -122,25 +122,30 @@ return_policy (struct MHD_Connection *connection,
{
char *sig_s;
char *etag;
+ char *etagq;
sig_s = GNUNET_STRINGS_data_to_string_alloc (&account_sig,
sizeof (account_sig));
- etag = GNUNET_STRINGS_data_to_string_alloc (&recovery_data_hash,
- sizeof (recovery_data_hash));
GNUNET_break (MHD_YES ==
MHD_add_response_header (resp,
ANASTASIS_HTTP_HEADER_POLICY_SIGNATURE,
sig_s));
+ GNUNET_free (sig_s);
GNUNET_break (MHD_YES ==
MHD_add_response_header (resp,
ANASTASIS_HTTP_HEADER_POLICY_VERSION,
version_s));
+ etag = GNUNET_STRINGS_data_to_string_alloc (&recovery_data_hash,
+ sizeof (recovery_data_hash));
+ GNUNET_asprintf (&etagq,
+ "\"%s\"",
+ etag);
+ GNUNET_free (etag);
GNUNET_break (MHD_YES ==
MHD_add_response_header (resp,
MHD_HTTP_HEADER_ETAG,
- etag));
- GNUNET_free (etag);
- GNUNET_free (sig_s);
+ etagq));
+ GNUNET_free (etagq);
}
{
MHD_RESULT ret;
@@ -203,13 +208,16 @@ AH_policy_get (struct MHD_Connection *connection,
inm = MHD_lookup_connection_value (connection,
MHD_HEADER_KIND,
MHD_HTTP_HEADER_IF_NONE_MATCH);
- if (NULL != inm)
+ if ( (NULL != inm) &&
+ (2 < strlen (inm)) &&
+ ('"' == inm[0]) &&
+ ('"' == inm[strlen (inm) - 1]) )
{
struct GNUNET_HashCode inm_h;
if (GNUNET_OK !=
- GNUNET_STRINGS_string_to_data (inm,
- strlen (inm),
+ GNUNET_STRINGS_string_to_data (inm + 1,
+ strlen (inm) - 2,
&inm_h,
sizeof (inm_h)))
{