diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-05-08 19:04:41 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-05-08 19:04:41 +0400 |
commit | 17f26fd5ed8adec7a8c2c69ddac1934e56dff0c9 (patch) | |
tree | 11abad819be7a8195a8418406c66dc5595d5cdcd /src/fstring.c | |
parent | fe2efaafebe67860ec3f5b3c259208ce7db05eeb (diff) | |
download | rspamd-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.c | 36 |
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; +} |