aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/http.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-15 14:24:06 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-15 14:24:06 +0100
commitc8cfd79d46bc857ef6a09fffa8a9de3c32729020 (patch)
tree4b81bcdafe449573533e04dbeeaa85903e764f2f /src/libutil/http.c
parent065b73d3df9bb9ff18cfbc653b18b37744a9c387 (diff)
downloadrspamd-c8cfd79d46bc857ef6a09fffa8a9de3c32729020.tar.gz
rspamd-c8cfd79d46bc857ef6a09fffa8a9de3c32729020.zip
Fix some more issues with fixed strings
Diffstat (limited to 'src/libutil/http.c')
-rw-r--r--src/libutil/http.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/libutil/http.c b/src/libutil/http.c
index 1dd22f309..e082c3c24 100644
--- a/src/libutil/http.c
+++ b/src/libutil/http.c
@@ -2394,7 +2394,7 @@ rspamd_http_message_parse_query (struct rspamd_http_message *msg)
{
GHashTable *res;
rspamd_fstring_t *key = NULL, *value = NULL;
- rspamd_ftok_t *key_tok, *value_tok;
+ rspamd_ftok_t *key_tok = NULL, *value_tok = NULL;
const gchar *p, *c, *end;
struct http_parser_url u;
enum {
@@ -2423,24 +2423,23 @@ rspamd_http_message_parse_query (struct rspamd_http_message *msg)
if ((*p == '&' || p == end) && p > c) {
/* We have a single parameter without a value */
key = rspamd_fstring_new_init (c, p - c);
- key_tok = g_slice_alloc (sizeof (*key_tok));
- key_tok->begin = key->str;
+ key_tok = rspamd_ftok_map (key);
key_tok->len = rspamd_decode_url (key->str, key->str,
key->len);
+
value = rspamd_fstring_new_init ("", 0);
- value_tok = g_slice_alloc (sizeof (*value_tok));
- value_tok->begin = value->str;
- value_tok->len = value->len;
- g_hash_table_insert (res, key_tok, value_tok);
+ value_tok = rspamd_ftok_map (value);
+
+ g_hash_table_replace (res, key_tok, value_tok);
state = parse_ampersand;
}
else if (*p == '=' && p > c) {
/* We have something like key=value */
key = rspamd_fstring_new_init (c, p - c);
- key_tok = g_slice_alloc (sizeof (*key_tok));
- key_tok->begin = key->str;
+ key_tok = rspamd_ftok_map (key);
key_tok->len = rspamd_decode_url (key->str, key->str,
key->len);
+
state = parse_eqsign;
}
else {
@@ -2463,21 +2462,19 @@ rspamd_http_message_parse_query (struct rspamd_http_message *msg)
g_assert (key != NULL);
if (p > c) {
value = rspamd_fstring_new_init (c, p - c);
- value_tok = g_slice_alloc (sizeof (*value_tok));
- value_tok->begin = value->str;
+ value_tok = rspamd_ftok_map (value);
value_tok->len = rspamd_decode_url (value->str,
value->str,
value->len);
}
else {
value = rspamd_fstring_new_init ("", 0);
- value_tok = g_slice_alloc (sizeof (*value_tok));
- value_tok->begin = value->str;
- value_tok->len = value->len;
+ value_tok = rspamd_ftok_map (value);
}
- g_hash_table_insert (res, key_tok, value_tok);
+ g_hash_table_replace (res, key_tok, value_tok);
key = value = NULL;
+ key_tok = value_tok = NULL;
state = parse_ampersand;
}
else {