]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libext2fs: check return values
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 12 Dec 2013 18:14:50 +0000 (13:14 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 12 Dec 2013 18:14:52 +0000 (13:14 -0500)
Fix up a few places where we ignore return values.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ext2fs/flushb.c
lib/ext2fs/icount.c
lib/ext2fs/imager.c
lib/ext2fs/mkjournal.c
lib/ext2fs/punch.c

index ac8923cb227dc17b25e6968ed1a2e50e5eb5c9c7..98821fc70ba1707e0bec6eb9e42f52b21b8c2969 100644 (file)
@@ -70,7 +70,7 @@ errcode_t ext2fs_sync_device(int fd, int flushb)
 #warning BLKFLSBUF not defined
 #endif
 #ifdef FDFLUSH
-               ioctl (fd, FDFLUSH, 0);   /* In case this is a floppy */
+               return ioctl(fd, FDFLUSH, 0);   /* In case this is a floppy */
 #elif defined(__linux__)
 #warning FDFLUSH not defined
 #endif
index 84b74a9a4bb46b84d77595b228bb214ab089ad30..c5ebf744c499d2e28b33027cfdd87c9d42bb0a44 100644 (file)
@@ -193,6 +193,8 @@ errcode_t ext2fs_create_icount_tdb(ext2_filsys fs, char *tdb_dir,
        uuid_unparse(fs->super->s_uuid, uuid);
        sprintf(fn, "%s/%s-icount-XXXXXX", tdb_dir, uuid);
        fd = mkstemp(fn);
+       if (fd < 0)
+               return fd;
 
        /*
         * This is an overestimate of the size that we will need; the
index 7f3b25b59a71db730e782209bb3f181684db1a81..378a3c885989be4cafc7151feb9e6f3844119737 100644 (file)
@@ -66,6 +66,7 @@ errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags)
        blk64_t         blk;
        ssize_t         actual;
        errcode_t       retval;
+       off_t           r;
 
        buf = malloc(fs->blocksize * BUF_BLOCKS);
        if (!buf)
@@ -97,7 +98,11 @@ errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags)
                                        blk++;
                                        left--;
                                        cp += fs->blocksize;
-                                       lseek(fd, fs->blocksize, SEEK_CUR);
+                                       r = lseek(fd, fs->blocksize, SEEK_CUR);
+                                       if (r < 0) {
+                                               retval = errno;
+                                               goto errout;
+                                       }
                                        continue;
                                }
                                /* Find non-zero blocks */
index 2afd3b7c8082a405d5b3a31ff11123b0c65abd2a..1d5b1a75e149b9905d3bc0d27bdd71048e33ce00 100644 (file)
@@ -520,8 +520,10 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t num_blocks, int flags)
 #if HAVE_EXT2_IOCTLS
                fd = open(jfile, O_RDONLY);
                if (fd >= 0) {
-                       ioctl(fd, EXT2_IOC_SETFLAGS, &f);
+                       retval = ioctl(fd, EXT2_IOC_SETFLAGS, &f);
                        close(fd);
+                       if (retval)
+                               return retval;
                }
 #endif
 #endif
index 790a0ad8588771438e75e16cdca476177d6711d8..ceec3367b1aa7a226f4610dd7c0cda393a2fa77e 100644 (file)
@@ -192,6 +192,13 @@ static errcode_t ext2fs_punch_extent(ext2_filsys fs, ext2_ino_t ino,
        retval = ext2fs_extent_open2(fs, ino, inode, &handle);
        if (retval)
                return retval;
+       /*
+        * Find the extent closest to the start of the punch range.  We don't
+        * check the return value because _goto() sets the current node to the
+        * next-lowest extent if 'start' is in a hole, and doesn't set a
+        * current node if there was a real error reading the extent tree.
+        * In that case, _get() will error out.
+        */
        ext2fs_extent_goto(handle, start);
        retval = ext2fs_extent_get(handle, EXT2_EXTENT_CURRENT, &extent);
        if (retval)