]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: log: add no_escape_map to bypass escape with _lf_encode_bytes()
authorAurelien DARRAGON <adarragon@haproxy.com>
Fri, 26 Apr 2024 12:23:43 +0000 (14:23 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Fri, 26 Apr 2024 16:39:31 +0000 (18:39 +0200)
Providing no_escape_map as <map> argument to _lf_encode_bytes() function
will make the function skip escaping since the map is empty.

This is for convenience, as it might be useful to call lf_encode_chunk()
to encoding binary data without escaping it.

src/log.c

index 07f4b231bc4cb5ce77d29bc04c2a9cfd8be0e975..491304692d899537d314e75fa2d1dca08f8f7e67 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -95,6 +95,7 @@ static const struct log_fmt_st log_formats[LOG_FORMATS] = {
  * that the byte should be escaped. Be careful to always pass bytes from 0 to
  * 255 exclusively to the macros.
  */
+long no_escape_map[(256/8) / sizeof(long)];
 long rfc5424_escape_map[(256/8) / sizeof(long)];
 long hdr_encode_map[(256/8) / sizeof(long)];
 long url_encode_map[(256/8) / sizeof(long)];
@@ -2847,6 +2848,9 @@ static void init_log()
        char *tmp;
        int i;
 
+       /* Initialize the no escape map, which may be used to bypass escaping */
+       memset(no_escape_map, 0, sizeof(no_escape_map));
+
        /* Initialize the escape map for the RFC5424 structured-data : '"\]'
         * inside PARAM-VALUE should be escaped with '\' as prefix.
         * See https://tools.ietf.org/html/rfc5424#section-6.3.3 for more