From 25086e6913738be8321789e46f77dd8405e1e280 Mon Sep 17 00:00:00 2001 From: Marek Schimara Date: Thu, 12 Sep 2013 13:57:50 +0200 Subject: [PATCH] src/rrd_open.c: fix crash (SIGBUS) trying to CREATE a rrd on a full filesystem Condition (posix_fallocate(rrd_simple_file->fd, 0, newfile_size) == -1) is always FALSE so this check passes all the time. See man posix_fallocate() --- src/rrd_open.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/rrd_open.c b/src/rrd_open.c index 2f1b003f..91b8e84f 100644 --- a/src/rrd_open.c +++ b/src/rrd_open.c @@ -279,8 +279,15 @@ rrd_file_t *rrd_open( } else { rrd_file->file_len = newfile_size; #ifdef HAVE_POSIX_FALLOCATE - if (posix_fallocate(rrd_simple_file->fd, 0, newfile_size) == 0){ - /* if all is well we skip the seeking below */ + /* man: posix_fallocate() returns zero on success, + * or an error number on failure. Note that errno is not set. + */ + int fret = posix_fallocate(rrd_simple_file->fd, 0, newfile_size); + if (fret) { + rrd_set_error("posix_fallocate '%s': %s", file_name, + rrd_strerror(fret)); + goto out_close; + } else { goto no_lseek_necessary; } #endif -- 2.47.2