aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/rrd.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-01 16:29:43 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-01 16:29:43 +0100
commitcabb46ca81c60638493e7842aeaba9166d5d34a9 (patch)
treeabf40495c7da3d99a70a4b4f00a4c5f3dc0e2a37 /src/libutil/rrd.c
parent13a9fc0e14d4f44f3f81234e774c5e7e5b08b917 (diff)
downloadrspamd-cabb46ca81c60638493e7842aeaba9166d5d34a9.tar.gz
rspamd-cabb46ca81c60638493e7842aeaba9166d5d34a9.zip
[Fix] Improve rrd diagnostic errors
Diffstat (limited to 'src/libutil/rrd.c')
-rw-r--r--src/libutil/rrd.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/libutil/rrd.c b/src/libutil/rrd.c
index 470896efa..a230faf2b 100644
--- a/src/libutil/rrd.c
+++ b/src/libutil/rrd.c
@@ -217,20 +217,30 @@ rspamd_rrd_check_file (const gchar *filename, gboolean need_data, GError **err)
return FALSE;
}
/* Check magic */
- if (memcmp (head.cookie, RRD_COOKIE, sizeof (head.cookie)) != 0 ||
- memcmp (head.version, RRD_VERSION, sizeof (head.version)) != 0 ||
- head.float_cookie != RRD_FLOAT_COOKIE) {
+ if (memcmp (head.version, RRD_VERSION, sizeof (head.version)) != 0) {
g_set_error (err,
- rrd_error_quark (), EINVAL, "rrd head cookies error: %s",
- strerror (errno));
+ rrd_error_quark (), EINVAL, "rrd head error: bad cookie");
+ close (fd);
+ return FALSE;
+ }
+ if (memcmp (head.version, RRD_VERSION, sizeof (head.version)) != 0) {
+ g_set_error (err,
+ rrd_error_quark (), EINVAL, "rrd head error: invalid version");
+ close (fd);
+ return FALSE;
+ }
+ if (head.float_cookie != RRD_FLOAT_COOKIE) {
+ g_set_error (err,
+ rrd_error_quark (), EINVAL, "rrd head error: another architecture "
+ "(file cookie %g != our cookie %g)",
+ head.float_cookie, RRD_FLOAT_COOKIE);
close (fd);
return FALSE;
}
/* Check for other params */
if (head.ds_cnt <= 0 || head.rra_cnt <= 0) {
g_set_error (err,
- rrd_error_quark (), EINVAL, "rrd head cookies error: %s",
- strerror (errno));
+ rrd_error_quark (), EINVAL, "rrd head cookies error: bad rra or ds count");
close (fd);
return FALSE;
}