aboutsummaryrefslogtreecommitdiffstats
path: root/src/fstring.c
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 /src/fstring.c
parentfe2efaafebe67860ec3f5b3c259208ce7db05eeb (diff)
downloadrspamd-17f26fd5ed8adec7a8c2c69ddac1934e56dff0c9.tar.gz
rspamd-17f26fd5ed8adec7a8c2c69ddac1934e56dff0c9.zip
* Strip header values to avoid problems with libc functions
Diffstat (limited to 'src/fstring.c')
-rw-r--r--src/fstring.c36
1 files changed, 36 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;
+}