]> source.dussan.org Git - rspamd.git/commitdiff
More fixes to parsing queries.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 11 Nov 2015 17:58:58 +0000 (17:58 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 11 Nov 2015 17:58:58 +0000 (17:58 +0000)
clang-plugin/printf_check.cc

index 821aae852e8e2a7120f3ee5634eb9d6874a0f1ef..1b8d015f6c731008c6a4c08520181bd2b7899b07 100644 (file)
@@ -229,7 +229,9 @@ namespace rspamd {
 
                        auto res = std::make_shared<std::vector<PrintfArgChecker> > ();
 
-                       for (const auto c : query) {
+                       for (auto citer = query.begin(); citer != query.end(); ++citer) {
+                               auto c = *citer;
+
                                switch (state) {
                                case ignore_chars:
                                        if (c == '%') {
@@ -251,14 +253,22 @@ namespace rspamd {
                                                /* %*s - need integer argument */
                                                res->emplace_back (int_arg_handler, this->pcontext,
                                                                this->ci);
-                                               state = read_arg;
+
+                                               if (*std::next (citer) == '.') {
+                                                       ++citer;
+                                                       state = read_precision;
+                                               }
+                                               else {
+                                                       state = read_arg;
+                                               }
                                        }
                                        else if (c == '%') {
                                                /* Percent character, ignore */
                                                state = ignore_chars;
                                        }
                                        else {
-                                               flags.push_back (c);
+                                               // Rewind iter
+                                               --citer;
                                                state = read_arg;
                                        }
                                        break;
@@ -272,7 +282,8 @@ namespace rspamd {
                                                precision = c - '0';
                                        }
                                        else {
-                                               flags.push_back (c);
+                                               // Rewind iter
+                                               --citer;
                                                state = read_arg;
                                        }
                                        break;
@@ -287,7 +298,8 @@ namespace rspamd {
                                                state = read_arg;
                                        }
                                        else {
-                                               flags.push_back (c);
+                                               // Rewind iter
+                                               --citer;
                                                state = read_arg;
                                        }
                                        break;
@@ -317,6 +329,8 @@ namespace rspamd {
                                                else {
                                                        state = ignore_chars;
                                                }
+                                               flags.clear ();
+                                               width = precision = 0;
                                        }
                                        else {
                                                flags.push_back (c);