From: Marek Schimara Date: Thu, 12 Sep 2013 11:57:50 +0000 (+0200) Subject: src/rrd_open.c: fix crash (SIGBUS) trying to CREATE a rrd on a full filesystem X-Git-Tag: v1.7.0~41^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F729%2Fhead;p=thirdparty%2Frrdtool-1.x.git 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() --- 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