]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Add gboolean check support.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 11 Nov 2015 17:26:06 +0000 (17:26 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 11 Nov 2015 17:26:06 +0000 (17:26 +0000)
clang-plugin/printf_check.cc

index 5d0411ab4b2db3fe7d842c88b23c40ef42a0f1b3..821aae852e8e2a7120f3ee5634eb9d6874a0f1ef 100644 (file)
@@ -75,6 +75,9 @@ namespace rspamd {
        static bool int32_arg_handler (const Expr *arg,
                        struct PrintfArgChecker *ctx);
 
+       static bool gboolean_arg_handler (const Expr *arg,
+                       struct PrintfArgChecker *ctx);
+
        static bool tok_arg_handler (const Expr *arg,
                        struct PrintfArgChecker *ctx);
 
@@ -187,6 +190,9 @@ 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);
@@ -350,7 +356,7 @@ namespace rspamd {
 
                        format_specs = {
                                        's', 'd', 'l', 'L', 'v', 'V', 'f', 'F', 'g', 'G',
-                                       'T', 'z', 'D', 'c', 'p', 'P', 'e'
+                                       'T', 'z', 'D', 'c', 'p', 'P', 'e', 'b'
                        };
                };
 
@@ -674,6 +680,15 @@ 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)