aboutsummaryrefslogtreecommitdiffstats
path: root/clang-plugin/printf_check.cc
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-11 17:58:58 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-11 17:58:58 +0000
commite4abacbe1ddd0f3e7e60a53aec5d93f96702b081 (patch)
tree8c6c2c8ba5255ede01c305de133c504adc2ebb2e /clang-plugin/printf_check.cc
parent8ca7e0347adc650e6f48de1156855d02194c88eb (diff)
downloadrspamd-e4abacbe1ddd0f3e7e60a53aec5d93f96702b081.tar.gz
rspamd-e4abacbe1ddd0f3e7e60a53aec5d93f96702b081.zip
More fixes to parsing queries.
Diffstat (limited to 'clang-plugin/printf_check.cc')
-rw-r--r--clang-plugin/printf_check.cc24
1 files changed, 19 insertions, 5 deletions
diff --git a/clang-plugin/printf_check.cc b/clang-plugin/printf_check.cc
index 821aae852..1b8d015f6 100644
--- a/clang-plugin/printf_check.cc
+++ b/clang-plugin/printf_check.cc
@@ -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);