]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
ext2fs_get_device_size(): Fix potential fd descriptor leak in an error case
authorTheodore Ts'o <tytso@mit.edu>
Thu, 19 Apr 2007 01:37:42 +0000 (21:37 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 19 Apr 2007 01:37:42 +0000 (21:37 -0400)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ext2fs/ChangeLog
lib/ext2fs/getsize.c

index 6ad08c7d07101a0178a4c6bf7f283b36929c91f9..9b2125199ce076d457956f3c27c4a254fc81591d 100644 (file)
@@ -1,3 +1,8 @@
+2007-04-18  Theodore Tso  <tytso@mit.edu>
+
+       * getsize.c (ext2fs_get_device_size): Make sure we don't leak a
+               file descriptor in some error cases.
+
 2007-04-14  Theodore Tso  <tytso@mit.edu>
 
        * swapfs.c (ext2fs_swap_inode_full): Fix a problem byte-swapping 
index 30a9c224fa2544f06ce928043da7bb4ec9a2bea6..7f6ef71b0e40991c845cebd21dc04af4b865d160 100644 (file)
@@ -170,8 +170,10 @@ errcode_t ext2fs_get_device_size(const char *file, int blocksize,
 #ifdef DKIOCGETBLOCKCOUNT      /* For Apple Darwin */
        if (ioctl(fd, DKIOCGETBLOCKCOUNT, &size64) >= 0) {
                if ((sizeof(*retblocks) < sizeof(unsigned long long))
-                   && ((size64 / (blocksize / 512)) > 0xFFFFFFFF))
-                       return EFBIG;
+                   && ((size64 / (blocksize / 512)) > 0xFFFFFFFF)) {
+                       rc = EFBIG;
+                       goto out;
+               }
                *retblocks = size64 / (blocksize / 512);
                goto out;
        }
@@ -281,8 +283,10 @@ errcode_t ext2fs_get_device_size(const char *file, int blocksize,
        valid_offset (fd, 0);
        size64 = low + 1;
        if ((sizeof(*retblocks) < sizeof(unsigned long long))
-           && ((size64 / blocksize) > 0xFFFFFFFF))
-               return EFBIG;
+           && ((size64 / blocksize) > 0xFFFFFFFF)) {
+               rc = EFBIG;
+               goto out;
+       }
        *retblocks = size64 / blocksize;
 out:
        close(fd);