From: Vsevolod Stakhov Date: Sat, 31 Mar 2018 16:41:19 +0000 (+0100) Subject: [Minor] Add macros to access strings data X-Git-Tag: 1.7.3~64 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7c09818f4165382cbd65a6a33b655a2def0ffc65;p=rspamd.git [Minor] Add macros to access strings data --- diff --git a/src/controller.c b/src/controller.c index 1685f7eb0..3ae0dbe07 100644 --- a/src/controller.c +++ b/src/controller.c @@ -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", diff --git a/src/libutil/fstring.h b/src/libutil/fstring.h index e83c44a1c..e5d34e022 100644 --- a/src/libutil/fstring.h +++ b/src/libutil/fstring.h @@ -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; diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c index fc4b43bea..a4e98a075 100644 --- a/src/rspamd_proxy.c +++ b/src/rspamd_proxy.c @@ -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);