From: Vsevolod Stakhov Date: Fri, 22 Aug 2014 22:36:56 +0000 (-0700) Subject: Fix issue with /getmap command. X-Git-Tag: 0.7.0~111 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=62aa50b09711c540a1fd8bbac09497664298b5b2;p=thirdparty%2Frspamd.git Fix issue with /getmap command. Issue: #3 Reported by: @prudnitskiy --- diff --git a/src/controller.c b/src/controller.c index 96e885cc9d..5794eca2fa 100644 --- a/src/controller.c +++ b/src/controller.c @@ -425,7 +425,7 @@ rspamd_controller_handle_maps (struct rspamd_http_connection_entry *conn_ent, cur = session->ctx->cfg->maps; while (cur) { map = cur->data; - if (map->protocol == MAP_PROTO_FILE && map->description != NULL) { + if (map->protocol == MAP_PROTO_FILE) { if (access (map->uri, R_OK) == 0) { tmp = g_list_prepend (tmp, map); } @@ -441,8 +441,10 @@ rspamd_controller_handle_maps (struct rspamd_http_connection_entry *conn_ent, obj = ucl_object_typed_new (UCL_OBJECT); ucl_object_insert_key (obj, ucl_object_fromint (map->id), "map", 0, false); - ucl_object_insert_key (obj, ucl_object_fromstring (map->description), - "description", 0, false); + if (map->description) { + ucl_object_insert_key (obj, ucl_object_fromstring (map->description), + "description", 0, false); + } ucl_object_insert_key (obj, ucl_object_frombool (editable), "editable", 0, false); ucl_array_append (top, obj); @@ -531,7 +533,7 @@ rspamd_controller_handle_get_map (struct rspamd_http_connection_entry *conn_ent, reply->body = g_string_sized_new (st.st_size); /* Read the whole buffer */ - if (read (fd, msg->body->str, st.st_size) == -1) { + if (read (fd, reply->body->str, st.st_size) == -1) { rspamd_http_message_free (reply); msg_err ("cannot read map %s: %s", map->uri, strerror (errno)); rspamd_controller_send_error (conn_ent, 500, "500 map read error");