]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
src/rrd_open.c: fix Coverity CID#32402 Unchecked return value from library
authorMarek Schimara <Marek.Schimara@bull.net>
Wed, 15 Jun 2016 14:12:47 +0000 (16:12 +0200)
committerMarek Schimara <Marek.Schimara@bull.net>
Thu, 23 Jun 2016 14:32:33 +0000 (16:32 +0200)
        CWE-252 / https://cwe.mitre.org/data/definitions/252.html

src/rrd_open.c

index 80a4a7951114fed8fa12386a4021e2db80392546..3bb2726636f138f8b717c89f288d0dff5b3e1e4e 100644 (file)
@@ -283,12 +283,18 @@ rrd_file_t *rrd_open(
             goto no_lseek_necessary;        
         }
 #endif
-        lseek(rrd_simple_file->fd, newfile_size - 1, SEEK_SET);
+        if (lseek(rrd_simple_file->fd, newfile_size - 1, SEEK_SET) == -1) {
+            rrd_set_error("lseek '%s': %s", file_name, rrd_strerror(errno));
+            goto out_close;
+        }
         if ( write(rrd_simple_file->fd, "\0", 1) == -1){    /* poke */
             rrd_set_error("write '%s': %s", file_name, rrd_strerror(errno));
             goto out_close;
         }
-        lseek(rrd_simple_file->fd, 0, SEEK_SET);
+        if (lseek(rrd_simple_file->fd, 0, SEEK_SET) == -1){
+            rrd_set_error("lseek '%s': %s", file_name, rrd_strerror(errno));
+            goto out_close;
+        }
     }
     no_lseek_necessary:
 #if !defined(HAVE_MMAP) && defined(HAVE_POSIX_FADVISE)