From: Vsevolod Stakhov Date: Wed, 11 Nov 2015 17:58:58 +0000 (+0000) Subject: More fixes to parsing queries. X-Git-Tag: 1.1.0~579 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e4abacbe1ddd0f3e7e60a53aec5d93f96702b081;p=thirdparty%2Frspamd.git More fixes to parsing queries. --- diff --git a/clang-plugin/printf_check.cc b/clang-plugin/printf_check.cc index 821aae852e..1b8d015f6c 100644 --- a/clang-plugin/printf_check.cc +++ b/clang-plugin/printf_check.cc @@ -229,7 +229,9 @@ namespace rspamd { auto res = std::make_shared > (); - 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);