[rs-commit] r423 - /mod_cms_verify/trunk/mod_cms_verify.c

rs-commit at redwax.eu rs-commit at redwax.eu
Sat Aug 7 22:52:40 CEST 2021


Author: dirkx at redwax.eu
Date: Sat Aug  7 22:52:39 2021
New Revision: 423

Log:
Move filter earlier in the Queue; but a bit more strict in the base64 as we're not using a real json parser.

Modified:
    mod_cms_verify/trunk/mod_cms_verify.c

Modified: mod_cms_verify/trunk/mod_cms_verify.c
==============================================================================
--- mod_cms_verify/trunk/mod_cms_verify.c	(original)
+++ mod_cms_verify/trunk/mod_cms_verify.c	Sat Aug  7 22:52:39 2021
@@ -253,7 +253,12 @@
         if (*ptr++ != '"')
 	   return "No start to the value";
 
-        for(n=0;ptr+n < end && ptr[n] != '"'; n++) {};
+        for(n=0;ptr+n < end && ptr[n] != '"'; n++) {
+		char c = ptr[n];
+		if (!isdigit(c) && !isalpha(c) && !isspace(c) && 
+		    c != '+' && c != '/' && c != '=' && c != '_' && c != '-')
+			return "Illegal base64 char";
+	};
         if (ptr >= end)
 	   return "No end to the value";
       
@@ -324,13 +329,13 @@
 		      ERR_reason_error_string(ERR_get_error()));
 	goto exit;
     };
-
     ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, HANDLER ": valid signature, subject=<%s>.", dn);
 
     if (ptr == NULL) {
     	len = BIO_get_mem_data(out, &ptr);
     	ptr = apr_pmemdup(r->pool, ptr, len);
     };
+
     ret = apr_bucket_pool_create(ptr, len, r->pool, r->connection->bucket_alloc);
 
 exit:
@@ -442,7 +447,7 @@
 static void _register_hooks(apr_pool_t * p)
 {
     ap_hook_pre_config(_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
-    ap_register_input_filter(HANDLER, _input_filter, NULL, AP_FTYPE_CONTENT_SET);
+    ap_register_input_filter(HANDLER, _input_filter, NULL, AP_FTYPE_RESOURCE);
 }
 
 static const command_rec _cmds[] =



More information about the rs-commit mailing list