commit ab4950c: [Minor] Allow unconditional special handlers
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Mar 26 18:28:03 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-03-26 15:41:04 +0000
URL: https://github.com/rspamd/rspamd/commit/ab4950c5eac19bd5d5aeac2a1c4772e9fd893f37
[Minor] Allow unconditional special handlers
---
contrib/libucl/ucl.h | 9 +++++++++
contrib/libucl/ucl_parser.c | 5 +++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/contrib/libucl/ucl.h b/contrib/libucl/ucl.h
index f7f8354c5..482812d46 100644
--- a/contrib/libucl/ucl.h
+++ b/contrib/libucl/ucl.h
@@ -1294,12 +1294,21 @@ typedef bool (*ucl_parser_special_handler_t) (struct ucl_parser *parser,
unsigned char **destination, size_t *dest_len,
void *user_data);
+/**
+ * Special handler flags
+ */
+enum ucl_special_handler_flags {
+ UCL_SPECIAL_HANDLER_DEFAULT = 0,
+ UCL_SPECIAL_HANDLER_PREPROCESS_ALL = (1u << 0),
+};
+
/**
* Special handler structure
*/
struct ucl_parser_special_handler {
const unsigned char *magic;
size_t magic_len;
+ enum ucl_special_handler_flags flags;
ucl_parser_special_handler_t handler;
void (*free_function) (unsigned char *data, size_t len, void *user_data);
void *user_data;
diff --git a/contrib/libucl/ucl_parser.c b/contrib/libucl/ucl_parser.c
index 574e240ab..59bfd7727 100644
--- a/contrib/libucl/ucl_parser.c
+++ b/contrib/libucl/ucl_parser.c
@@ -2862,8 +2862,9 @@ ucl_parser_add_chunk_full (struct ucl_parser *parser, const unsigned char *data,
memset (chunk, 0, sizeof (*chunk));
LL_FOREACH (parser->special_handlers, special_handler) {
- if (len >= special_handler->magic_len &&
- memcmp (data, special_handler->magic, special_handler->magic_len) == 0) {
+ if ((special_handler->flags & UCL_SPECIAL_HANDLER_PREPROCESS_ALL) ||
+ (len >= special_handler->magic_len &&
+ memcmp (data, special_handler->magic, special_handler->magic_len) == 0)) {
unsigned char *ndata = NULL;
size_t nlen = 0;
More information about the Commits
mailing list