]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
src/rrd_open.c: fix crash (SIGBUS) trying to CREATE a rrd on a full filesystem 729/head
authorMarek Schimara <Marek.Schimara@ext.bull.net>
Thu, 12 Sep 2013 11:57:50 +0000 (13:57 +0200)
committerMarek Schimara <Marek.Schimara@bull.net>
Tue, 23 Aug 2016 11:42:16 +0000 (13:42 +0200)
        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

index 2f1b003fe9415d46e35d53268f68d5f793703344..91b8e84f1041ee8246fc663e5e471be7e2a90100 100644 (file)
@@ -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