diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-07-09 20:44:57 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-07-09 20:44:57 +0100 |
commit | 41d4dbca113d696d5628f071869d18834d419733 (patch) | |
tree | 24c1b542525192093994f137e74a99e125b3f3d0 | |
parent | 3bf1e3a890638b4b908da3597bae4f434fc79144 (diff) | |
download | rspamd-41d4dbca113d696d5628f071869d18834d419733.tar.gz rspamd-41d4dbca113d696d5628f071869d18834d419733.zip |
[Fix] Fix several issues with the HTTP keepalive parsing
-rw-r--r-- | src/libserver/http/http_context.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/libserver/http/http_context.c b/src/libserver/http/http_context.c index 81e22bb52..4366e20ba 100644 --- a/src/libserver/http/http_context.c +++ b/src/libserver/http/http_context.c @@ -578,25 +578,24 @@ rspamd_http_parse_keepalive_timeout (const rspamd_ftok_t *tok) { long timeout = -1; goffset pos = rspamd_substring_search (tok->begin, - tok->len, "timeout=", sizeof ("timeout=") - 1); + tok->len, "timeout", sizeof ("timeout") - 1); if (pos != -1) { - pos += sizeof ("timeout=") - 1; + pos += sizeof ("timeout") - 1; - gchar *end_pos = memchr (tok->begin + pos, ',', tok->len - pos); - glong real_timeout; - - if (end_pos) { - if (rspamd_strtol (tok->begin + pos + 1, - (end_pos - tok->begin) - pos - 1, &real_timeout) && - real_timeout > 0) { - timeout = real_timeout; - msg_debug_http_context ("got timeout attr %.2f", timeout); + /* Skip spaces and equal sign */ + while (pos < tok->len) { + if (tok->begin[pos] != '=' && !g_ascii_isspace(tok->begin[pos])) { + break; } + pos ++; } - else { - if (rspamd_strtol (tok->begin + pos + 1, - tok->len - pos, &real_timeout) && real_timeout > 0) { + + gsize ndigits = rspamd_memspn(tok->begin + pos, "0123456789", tok->len - pos); + glong real_timeout; + + if (ndigits > 0) { + if (rspamd_strtoul(tok->begin + pos,ndigits, &real_timeout)) { timeout = real_timeout; msg_debug_http_context ("got timeout attr %.2f", timeout); } |