summaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-05-13 14:04:11 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-05-13 14:04:11 +0100
commitae6e8aa9ed5f92e8fc656e901eecee94c9b708b6 (patch)
tree6c0f7cd9d65369878dbb054910fe05db1c7484d7 /src/libutil
parent2d94c35b631d5d74bba56037a406bb125181e623 (diff)
downloadrspamd-ae6e8aa9ed5f92e8fc656e901eecee94c9b708b6.tar.gz
rspamd-ae6e8aa9ed5f92e8fc656e901eecee94c9b708b6.zip
Fix critical bug with reading file maps.
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/map.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libutil/map.c b/src/libutil/map.c
index 20c7d0e4c..c2de77ead 100644
--- a/src/libutil/map.c
+++ b/src/libutil/map.c
@@ -237,7 +237,7 @@ read_map_file (struct rspamd_map *map, struct file_map_data *data)
struct map_cb_data cbdata;
gchar buf[BUFSIZ], *remain;
ssize_t r;
- gint fd, rlen;
+ gint fd, rlen, tlen;
if (map->read_callback == NULL || map->fin_callback == NULL) {
msg_err ("bad callback for reading map file");
@@ -256,8 +256,10 @@ read_map_file (struct rspamd_map *map, struct file_map_data *data)
cbdata.map = map;
rlen = 0;
+ tlen = 0;
while ((r = read (fd, buf + rlen, sizeof (buf) - rlen - 1)) > 0) {
r += rlen;
+ tlen += r;
buf[r] = '\0';
remain = map->read_callback (map->pool, buf, r, &cbdata);
if (remain != NULL) {
@@ -269,7 +271,7 @@ read_map_file (struct rspamd_map *map, struct file_map_data *data)
close (fd);
- if (rlen > 0) {
+ if (tlen > 0) {
map->fin_callback (map->pool, &cbdata);
*map->user_data = cbdata.cur_data;
}