]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Remove ambigious format flag from printf
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 27 Oct 2018 16:56:47 +0000 (17:56 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 27 Oct 2018 16:56:47 +0000 (17:56 +0100)
clang-plugin/printf_check.cc
src/libserver/cfg_rcl.c
src/libutil/printf.c
src/libutil/printf.h
src/rspamadm/configdump.c

index 9b4819d08fbe66a5788f3cb9239edbf48015daa4..f8a78aa0b130a23cf7456293c50517bb48cf7ece 100644 (file)
@@ -187,9 +187,6 @@ namespace rspamd {
                        case 'D':
                                return llvm::make_unique<PrintfArgChecker> (int32_arg_handler,
                                                this->pcontext, this->ci);
-                       case 'B':
-                               return llvm::make_unique<PrintfArgChecker> (gboolean_arg_handler,
-                                               this->pcontext, this->ci);
                        case 'T':
                                return llvm::make_unique<PrintfArgChecker> (tok_arg_handler,
                                                this->pcontext, this->ci);
@@ -369,7 +366,7 @@ namespace rspamd {
 
                        format_specs = {
                                        's', 'd', 'l', 'L', 'v', 'V', 'f', 'F', 'g', 'G',
-                                       'T', 'z', 'D', 'c', 'p', 'P', 'e', 'B'
+                                       'T', 'z', 'D', 'c', 'p', 'P', 'e'
                        };
                };
 
@@ -719,15 +716,6 @@ namespace rspamd {
                return true;
        }
 
-       static bool
-       gboolean_arg_handler (const Expr *arg, struct PrintfArgChecker *ctx)
-       {
-               return check_builtin_type (arg,
-                               ctx,
-                               {BuiltinType::Kind::Int}, // gboolean is int in fact
-                               "%b");
-       }
-
        static bool
        check_struct_type (const Expr *arg, struct PrintfArgChecker *ctx,
                        const std::string &sname, const std::string &fmt)
index 8d18335d2dd2074793bffd6953dc1e4a39b3ed0a..a96cd6b6788bd682d669c5cbc2a2beff6877da5c 100644 (file)
@@ -2509,7 +2509,8 @@ rspamd_rcl_parse_struct_string (rspamd_mempool_t *pool,
                break;
        case UCL_BOOLEAN:
                *target = rspamd_mempool_alloc (pool, num_str_len);
-               rspamd_snprintf (*target, num_str_len, "%B", (gboolean)obj->value.iv);
+               rspamd_snprintf (*target, num_str_len, "%s",
+                               ((gboolean)obj->value.iv) ? "true" : "false");
                break;
        default:
                g_set_error (err,
@@ -2869,7 +2870,8 @@ rspamd_rcl_parse_struct_string_list (rspamd_mempool_t *pool,
                        break;
                case UCL_BOOLEAN:
                        val = rspamd_mempool_alloc (pool, num_str_len);
-                       rspamd_snprintf (val, num_str_len, "%B", (gboolean)cur->value.iv);
+                       rspamd_snprintf (val, num_str_len, "%s",
+                                       ((gboolean)cur->value.iv) ? "true" : "false");
                        break;
                default:
                        g_set_error (err,
index 7ee4d35e6983f2fb9e3866ed552e6beaf1958446..148b49d9ed9e48062770dde02730c0d30cb667c1 100644 (file)
@@ -602,7 +602,6 @@ rspamd_vprintf_common (rspamd_printf_append_func func,
        rspamd_ftok_t *tok;
        GString *gs;
        GError *err;
-       gboolean bv;
 
        while (*fmt) {
 
@@ -969,12 +968,6 @@ rspamd_vprintf_common (rspamd_printf_append_func func,
 
                                continue;
 
-                       case 'B':
-                               bv = (gboolean) va_arg (args, double);
-                               RSPAMD_PRINTF_APPEND (bv ? "true" : "false", bv ? 4 : 5);
-
-                               continue;
-
                        case 'p':
                                ui64 = (uintptr_t) va_arg (args, void *);
                                hex = 2;
index 73787d3a5a8916b9d060a14b6aa6b4ea493dd6b7..86947f67c7303d12de70c4294eadb5a13df2e3b5 100644 (file)
@@ -32,7 +32,6 @@
  *     %[0][width][.width]F        long double
  *     %[0][width][.width]g        double
  *     %[0][width][.width]G        long double
- *     %B                          boolean (true or false)
  *     %P                                                  pid_t
  *     %r                                          rlim_t
  *     %p                                                  void *
index 962089437a6d12ccee4751e9097e7f6b3445200a..cf08ceac0a662a3e52825a5133cd448c6f190e35 100644 (file)
@@ -143,8 +143,8 @@ rspamadm_add_doc_elt (const ucl_object_t *obj, const ucl_object_t *doc_obj,
 
        elt = ucl_object_lookup (doc_obj, "required");
        if (elt) {
-               rspamd_printf_fstring (&comment, " * Required: %B",
-                               ucl_object_toboolean (elt));
+               rspamd_printf_fstring (&comment, " * Required: %s",
+                               ucl_object_toboolean (elt) ? "true" : "false");
                cur_comment = ucl_object_fromstring_common (comment->str, comment->len, 0);
                rspamd_fstring_erase (comment, 0, comment->len);
                DL_APPEND (nobj, cur_comment);