summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-05-08 19:04:41 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-05-08 19:04:41 +0400
commit17f26fd5ed8adec7a8c2c69ddac1934e56dff0c9 (patch)
tree11abad819be7a8195a8418406c66dc5595d5cdcd
parentfe2efaafebe67860ec3f5b3c259208ce7db05eeb (diff)
downloadrspamd-17f26fd5ed8adec7a8c2c69ddac1934e56dff0c9.tar.gz
rspamd-17f26fd5ed8adec7a8c2c69ddac1934e56dff0c9.zip
* Strip header values to avoid problems with libc functions
-rw-r--r--src/fstring.c36
-rw-r--r--src/fstring.h5
-rw-r--r--src/protocol.c2
3 files changed, 43 insertions, 0 deletions
diff --git a/src/fstring.c b/src/fstring.c
index 2202effaf..935c8bdcc 100644
--- a/src/fstring.c
+++ b/src/fstring.c
@@ -338,3 +338,39 @@ fstrhash (f_str_t *str)
}
return hval;
}
+
+void
+fstrstrip (f_str_t *str)
+{
+ char *p = str->begin;
+ int r = 0;
+
+ while (r < str->len) {
+ if (g_ascii_isspace (*p)) {
+ p ++;
+ r ++;
+ }
+ else {
+ break;
+ }
+ }
+
+ if (r > 0) {
+ memmove (str->begin, p, str->len - r);
+ str->len -= r;
+ }
+
+ r = str->len;
+ p = str->begin + str->len;
+ while (r > 0) {
+ if (g_ascii_isspace (*p)) {
+ p --;
+ r --;
+ }
+ else {
+ break;
+ }
+ }
+
+ str->len = r;
+}
diff --git a/src/fstring.h b/src/fstring.h
index f5d7fffa3..00fac9039 100644
--- a/src/fstring.h
+++ b/src/fstring.h
@@ -98,4 +98,9 @@ uint32_t fstrhash (f_str_t *str);
*/
char* fstrcstr (f_str_t *str, memory_pool_t *pool);
+/*
+ * Strip fstr string from space symbols
+ */
+void fstrstrip (f_str_t *str);
+
#endif
diff --git a/src/protocol.c b/src/protocol.c
index a330334f8..49a86661b 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -100,6 +100,7 @@ separate_command (f_str_t *in, char c)
if (*p == c) {
*p = '\0';
in->begin = p + 1;
+ in->len -= r + 1;
return b;
}
p ++;
@@ -225,6 +226,7 @@ parse_header (struct worker_task *task, f_str_t *line)
}
/* Eat whitespaces */
g_strstrip (headern);
+ fstrstrip (line);
switch (headern[0]) {
case 'c':