aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/printf.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-01-11 13:03:24 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-01-11 13:03:24 +0000
commitf8d6761a366a3d884c85410ec356d4c4927a8697 (patch)
treec97d3dd8530c5e60ccb6c8d1c6e9567bc6a013bc /src/libutil/printf.c
parent1c11c280f0db0b6386aa2adf1d94a00dd72c9640 (diff)
downloadrspamd-f8d6761a366a3d884c85410ec356d4c4927a8697.tar.gz
rspamd-f8d6761a366a3d884c85410ec356d4c4927a8697.zip
[Minor] Core: Add support for hex encoded characters in printf
Diffstat (limited to 'src/libutil/printf.c')
-rw-r--r--src/libutil/printf.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libutil/printf.c b/src/libutil/printf.c
index 148b49d9e..476c4de40 100644
--- a/src/libutil/printf.c
+++ b/src/libutil/printf.c
@@ -979,7 +979,17 @@ rspamd_vprintf_common (rspamd_printf_append_func func,
case 'c':
c = va_arg (args, gint);
c &= 0xff;
- RSPAMD_PRINTF_APPEND (&c, 1);
+ if (G_UNLIKELY (hex)) {
+ gchar hexbuf[2];
+ hexbuf[0] = hex == 2 ? _HEX[(c >> 4) & 0xf] :
+ _hex[(c >> 4) & 0xf];
+ hexbuf[1] = hex == 2 ? _HEX[c & 0xf] : _hex[c & 0xf];
+
+ RSPAMD_PRINTF_APPEND (hexbuf, 2);
+ }
+ else {
+ RSPAMD_PRINTF_APPEND (&c, 1);
+ }
continue;