]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add macros to access strings data
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 31 Mar 2018 16:41:19 +0000 (17:41 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 31 Mar 2018 16:41:19 +0000 (17:41 +0100)
src/controller.c
src/libutil/fstring.h
src/rspamd_proxy.c

index 1685f7eb021f05d63b0eca2b1597d6cf87dbef8f..3ae0dbe079fd3528e62b4e94ab78db7bd3efe878 100644 (file)
@@ -1725,15 +1725,17 @@ rspamd_controller_handle_lua (struct rspamd_http_connection_entry *conn_ent,
        /* Find lua script */
        if (msg->url != NULL && msg->url->len != 0) {
 
-               http_parser_parse_url (msg->url->str, msg->url->len, TRUE, &u);
+               http_parser_parse_url (RSPAMD_FSTRING_DATA (msg->url),
+                               RSPAMD_FSTRING_LEN (msg->url), TRUE, &u);
 
                if (u.field_set & (1 << UF_PATH)) {
-                       lookup.begin = msg->url->str + u.field_data[UF_PATH].off;
+                       lookup.begin = RSPAMD_FSTRING_DATA (msg->url) +
+                                       u.field_data[UF_PATH].off;
                        lookup.len = u.field_data[UF_PATH].len;
                }
                else {
-                       lookup.begin = msg->url->str;
-                       lookup.len = msg->url->len;
+                       lookup.begin = RSPAMD_FSTRING_DATA (msg->url);
+                       lookup.len = RSPAMD_FSTRING_LEN (msg->url);
                }
 
                rspamd_snprintf (filebuf, sizeof (filebuf), "%s%c%T",
index e83c44a1cf138813846589c6b5bbd25e83266b54..e5d34e02212892ab7c17c1d185e9a2bcca82d57a 100644 (file)
@@ -30,6 +30,9 @@ typedef struct f_str_s {
        gchar str[];
 } rspamd_fstring_t;
 
+#define RSPAMD_FSTRING_DATA(s) ((s)->str)
+#define RSPAMD_FSTRING_LEN(s) ((s)->len)
+
 typedef struct f_str_tok {
        gsize len;
        const gchar *begin;
index fc4b43bea5d7ff45504dc8dda6083d2a99864c16..a4e98a07597ce592db9fb5d374e9016cafae6e96 100644 (file)
@@ -1229,7 +1229,8 @@ proxy_check_file (struct rspamd_http_message *msg,
        }
        else {
                /* Need to parse query URL */
-               if (http_parser_parse_url (msg->url->str, msg->url->len, 0, &u) != 0) {
+               if (http_parser_parse_url (RSPAMD_FSTRING_DATA (msg->url),
+                               RSPAMD_FSTRING_LEN (msg->url), 0, &u) != 0) {
                        msg_err_session ("bad request url: %V", msg->url);
 
                        return FALSE;
@@ -1258,7 +1259,7 @@ proxy_check_file (struct rspamd_http_message *msg,
                                }
 
                                /* We need to create a new URL with file attribute removed */
-                               new_url = rspamd_fstring_new_init (msg->url->str,
+                               new_url = rspamd_fstring_new_init (RSPAMD_FSTRING_DATA (msg->url),
                                                u.field_data[UF_QUERY].off);
                                new_url = rspamd_fstring_append (new_url, "?", 1);