]> git.sven.stormbind.net Git - sven/exfatprogs.git/commitdiff
New upstream version 1.1.3 upstream/1.1.3
authorSven Hoexter <sven@stormbind.net>
Wed, 17 Nov 2021 19:04:53 +0000 (20:04 +0100)
committerSven Hoexter <sven@stormbind.net>
Wed, 17 Nov 2021 19:04:53 +0000 (20:04 +0100)
12 files changed:
COPYING
Makefile.in
NEWS
README.md
configure
fsck/fsck.c
include/libexfat.h
include/list.h
include/version.h
lib/libexfat.c
mkfs/mkfs.c
mkfs/upcase.c

diff --git a/COPYING b/COPYING
index 941c87de278af88468e104290d62809713ee9ab3..d159169d1050894d3ea3b98e1c965c4058208fe1 100644 (file)
--- a/COPYING
+++ b/COPYING
@@ -56,7 +56,7 @@ patent must be licensed for everyone's free use or not licensed at all.
   The precise terms and conditions for copying, distribution and
 modification follow.
 
   The precise terms and conditions for copying, distribution and
 modification follow.
 
-                           GNU GENERAL PUBLIC LICENSE
+                    GNU GENERAL PUBLIC LICENSE
    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
 
   0. This License applies to any program or other work which contains
    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
 
   0. This License applies to any program or other work which contains
@@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
 POSSIBILITY OF SUCH DAMAGES.
 
 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
 POSSIBILITY OF SUCH DAMAGES.
 
-                           END OF TERMS AND CONDITIONS
+                     END OF TERMS AND CONDITIONS
 
 
-               How to Apply These Terms to Your New Programs
+            How to Apply These Terms to Your New Programs
 
   If you develop a new program, and you want it to be of the greatest
 possible use to the public, the best way to achieve this is to make it
 
   If you develop a new program, and you want it to be of the greatest
 possible use to the public, the best way to achieve this is to make it
index 5149426590cdd35f7d7ea2291cf2bf9c3c3e5b39..2fe793ae43d5b95fb9bdb6c62604a1ab34f76c76 100644 (file)
@@ -198,7 +198,7 @@ am__DIST_COMMON = $(dist_man8_MANS) $(srcdir)/Makefile.in \
        $(top_srcdir)/build-aux/install-sh \
        $(top_srcdir)/build-aux/ltmain.sh \
        $(top_srcdir)/build-aux/missing COPYING NEWS build-aux/compile \
        $(top_srcdir)/build-aux/install-sh \
        $(top_srcdir)/build-aux/ltmain.sh \
        $(top_srcdir)/build-aux/missing COPYING NEWS build-aux/compile \
-       build-aux/config.guess build-aux/config.sub \
+       build-aux/config.guess build-aux/config.sub build-aux/depcomp \
        build-aux/install-sh build-aux/ltmain.sh build-aux/missing
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
        build-aux/install-sh build-aux/ltmain.sh build-aux/missing
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
diff --git a/NEWS b/NEWS
index e2d53dc58e25114946cebbc33dce3cec8204c912..4f5ad6c2b86b419801d3da46159ae4904a285bc7 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,16 @@
+exfatprogs 1.1.3 - released 2021-11-11
+======================================
+
+CHANGES :
+ * mkfs.exfat: ensure that the cluster size is greater than or
+   equal than the sector size.
+ * mkfs.exfat: replace lseek() + write() with pwrite().
+
+BUG FIXES :
+ * mkfs.exfat: prevent an integer overflow when computing the FAT
+   length.
+ * fsck.exfat: fix a double free memory error.
+
 exfatprogs 1.1.2 - released 2021-05-20
 ======================================
 
 exfatprogs 1.1.2 - released 2021-05-20
 ======================================
 
index 4db98fda222236dcee8ddf32b0a995bbd9351813..b3fbdd0d974faac37ad3254274733fd2c501f19d 100644 (file)
--- a/README.md
+++ b/README.md
@@ -116,4 +116,4 @@ If you have any issues, please create [issues][1] or contact to [Namjae Jeon](ma
 
 ## Contributor information
 * Please base your pull requests on the `exfat-next` branch.
 
 ## Contributor information
 * Please base your pull requests on the `exfat-next` branch.
-* Make sure you add 'Signed-Off' information to your commits (e. g. `git commit --signoff`).
+* Make sure you add 'Signed-Off' information to your commits (e.g. `git commit --signoff`).
index c59011416bb99db98b184a2b85db484cb9762dba..f2c6a740c8c748f59c1e255f20ccd74dce3a8557 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for exfatprogs 1.1.2.
+# Generated by GNU Autoconf 2.69 for exfatprogs 1.1.3.
 #
 # Report bugs to <linkinjeon@kernel.org>.
 #
 #
 # Report bugs to <linkinjeon@kernel.org>.
 #
@@ -590,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='exfatprogs'
 PACKAGE_TARNAME='exfatprogs'
 # Identity of this package.
 PACKAGE_NAME='exfatprogs'
 PACKAGE_TARNAME='exfatprogs'
-PACKAGE_VERSION='1.1.2'
-PACKAGE_STRING='exfatprogs 1.1.2'
+PACKAGE_VERSION='1.1.3'
+PACKAGE_STRING='exfatprogs 1.1.3'
 PACKAGE_BUGREPORT='linkinjeon@kernel.org'
 PACKAGE_URL='https://github.com/exfatprogs/exfatprogs'
 
 PACKAGE_BUGREPORT='linkinjeon@kernel.org'
 PACKAGE_URL='https://github.com/exfatprogs/exfatprogs'
 
@@ -1325,7 +1325,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures exfatprogs 1.1.2 to adapt to many kinds of systems.
+\`configure' configures exfatprogs 1.1.3 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1396,7 +1396,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of exfatprogs 1.1.2:";;
+     short | recursive ) echo "Configuration of exfatprogs 1.1.3:";;
    esac
   cat <<\_ACEOF
 
    esac
   cat <<\_ACEOF
 
@@ -1508,7 +1508,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-exfatprogs configure 1.1.2
+exfatprogs configure 1.1.3
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1786,7 +1786,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by exfatprogs $as_me 1.1.2, which was
+It was created by exfatprogs $as_me 1.1.3, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2654,7 +2654,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='exfatprogs'
 
 # Define the identity of the package.
  PACKAGE='exfatprogs'
- VERSION='1.1.2'
+ VERSION='1.1.3'
 
 
 cat >>confdefs.h <<_ACEOF
 
 
 cat >>confdefs.h <<_ACEOF
@@ -13256,7 +13256,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by exfatprogs $as_me 1.1.2, which was
+This file was extended by exfatprogs $as_me 1.1.3, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -13323,7 +13323,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-exfatprogs config.status 1.1.2
+exfatprogs config.status 1.1.3
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
index 00d1ca7f2c3620770547fc014ffc14a2d99d70e3..6131d13dc43cdf4d26067feebf735c1dea355d36 100644 (file)
@@ -261,7 +261,7 @@ static void exfat_free_dir_list(struct exfat *exfat)
 
 /*
  * get references of ancestors that include @child until the count of
 
 /*
  * get references of ancestors that include @child until the count of
- * ancesters is not larger than @count and the count of characters of
+ * ancestors is not larger than @count and the count of characters of
  * their names is not larger than @max_char_len.
  * return true if root is reached.
  */
  * their names is not larger than @max_char_len.
  * return true if root is reached.
  */
@@ -1477,6 +1477,11 @@ static char *bytes_to_human_readable(size_t bytes)
                shift += 10;
        }
 
                shift += 10;
        }
 
+       if (i >= sizeof(units)/sizeof(units[0])) {
+               i = i - 1;
+               shift = shift - 10;
+       }
+
        quoti = (unsigned int)(bytes / (1ULL << shift));
        remain = 0;
        if (shift > 0) {
        quoti = (unsigned int)(bytes / (1ULL << shift));
        remain = 0;
        if (shift > 0) {
@@ -1596,8 +1601,10 @@ int main(int argc, char * const argv[])
                goto err;
 
        ret = init_exfat(exfat, bs);
                goto err;
 
        ret = init_exfat(exfat, bs);
-       if (ret)
+       if (ret) {
+               exfat = NULL;
                goto err;
                goto err;
+       }
 
        if (exfat_mark_volume_dirty(exfat, true)) {
                ret = -EIO;
 
        if (exfat_mark_volume_dirty(exfat, true)) {
                ret = -EIO;
index fecd7f23719bebd3d0db5650eed5cc533c70afc2..53a82a1efb31038d3c31d574b6487f6646a154ab 100644 (file)
@@ -34,7 +34,7 @@
 
 #define VOLUME_LABEL_BUFFER_SIZE       (VOLUME_LABEL_MAX_LEN*MB_LEN_MAX+1)
 
 
 #define VOLUME_LABEL_BUFFER_SIZE       (VOLUME_LABEL_MAX_LEN*MB_LEN_MAX+1)
 
-/* Upcase tabel macro */
+/* Upcase table macro */
 #define EXFAT_UPCASE_TABLE_SIZE                (5836)
 
 /* Flags for tune.exfat and exfatlabel */
 #define EXFAT_UPCASE_TABLE_SIZE                (5836)
 
 /* Flags for tune.exfat and exfatlabel */
index 30a32de9488835384133ba6ac851388341800375..cc93668aed30c76e8902dc5d0e219db435ddc375 100644 (file)
@@ -84,7 +84,6 @@ static inline void list_add_tail(struct list_head *new, struct list_head *head)
        __list_add(new, head->prev, head);
 }
 
        __list_add(new, head->prev, head);
 }
 
-
 /*
  * Delete a list entry by making the prev/next entries
  * point to each other.
 /*
  * Delete a list entry by making the prev/next entries
  * point to each other.
@@ -111,8 +110,6 @@ static inline void list_del(struct list_head *entry)
        entry->prev = LIST_POISON2;
 }
 
        entry->prev = LIST_POISON2;
 }
 
-
-
 /**
  * list_del_init - deletes entry from list and reinitialize it.
  * @entry: the element to delete from the list.
 /**
  * list_del_init - deletes entry from list and reinitialize it.
  * @entry: the element to delete from the list.
index 0f8a4630f8289c5b77c229d6ffab5d6d31729484..da9be8d84c2f6ac09ac6bcf0732324e8aa76e1ea 100644 (file)
@@ -5,6 +5,6 @@
 
 #ifndef _VERSION_H
 
 
 #ifndef _VERSION_H
 
-#define EXFAT_PROGS_VERSION "1.1.2"
+#define EXFAT_PROGS_VERSION "1.1.3"
 
 #endif /* !_VERSION_H */
 
 #endif /* !_VERSION_H */
index c54a7c8dc23bdb067acd218c9f1c28834b3da92b..c1c9b037c612a4e6bc24704aace55e6a4aaa529c 100644 (file)
@@ -475,8 +475,7 @@ int exfat_read_sector(struct exfat_blk_dev *bd, void *buf, unsigned int sec_off)
        int ret;
        unsigned long long offset = sec_off * bd->sector_size;
 
        int ret;
        unsigned long long offset = sec_off * bd->sector_size;
 
-       lseek(bd->dev_fd, offset, SEEK_SET);
-       ret = read(bd->dev_fd, buf, bd->sector_size);
+       ret = pread(bd->dev_fd, buf, bd->sector_size, offset);
        if (ret < 0) {
                exfat_err("read failed, sec_off : %u\n", sec_off);
                return -1;
        if (ret < 0) {
                exfat_err("read failed, sec_off : %u\n", sec_off);
                return -1;
@@ -490,8 +489,7 @@ int exfat_write_sector(struct exfat_blk_dev *bd, void *buf,
        int bytes;
        unsigned long long offset = sec_off * bd->sector_size;
 
        int bytes;
        unsigned long long offset = sec_off * bd->sector_size;
 
-       lseek(bd->dev_fd, offset, SEEK_SET);
-       bytes = write(bd->dev_fd, buf, bd->sector_size);
+       bytes = pwrite(bd->dev_fd, buf, bd->sector_size, offset);
        if (bytes != (int)bd->sector_size) {
                exfat_err("write failed, sec_off : %u, bytes : %d\n", sec_off,
                        bytes);
        if (bytes != (int)bd->sector_size) {
                exfat_err("write failed, sec_off : %u, bytes : %d\n", sec_off,
                        bytes);
index 8c812213dda3728a2e597cba3c94667f9ab4801f..b5b4957c72158bf844c2b69a4d4bb9a2b448d01c 100644 (file)
@@ -46,14 +46,14 @@ static void exfat_setup_boot_sector(struct pbr *ppbr,
        struct bsx64 *pbsx = &ppbr->bsx;
        unsigned int i;
 
        struct bsx64 *pbsx = &ppbr->bsx;
        unsigned int i;
 
-       /* Fill exfat BIOS paramemter block */
+       /* Fill exfat BIOS parameter block */
        pbpb->jmp_boot[0] = 0xeb;
        pbpb->jmp_boot[1] = 0x76;
        pbpb->jmp_boot[2] = 0x90;
        memcpy(pbpb->oem_name, "EXFAT   ", 8);
        memset(pbpb->res_zero, 0, 53);
 
        pbpb->jmp_boot[0] = 0xeb;
        pbpb->jmp_boot[1] = 0x76;
        pbpb->jmp_boot[2] = 0x90;
        memcpy(pbpb->oem_name, "EXFAT   ", 8);
        memset(pbpb->res_zero, 0, 53);
 
-       /* Fill exfat extend BIOS paramemter block */
+       /* Fill exfat extend BIOS parameter block */
        pbsx->vol_offset = cpu_to_le64(bd->offset / bd->sector_size);
        pbsx->vol_length = cpu_to_le64(bd->size / bd->sector_size);
        pbsx->fat_offset = cpu_to_le32(finfo.fat_byte_off / bd->sector_size);
        pbsx->vol_offset = cpu_to_le64(bd->offset / bd->sector_size);
        pbsx->vol_length = cpu_to_le64(bd->size / bd->sector_size);
        pbsx->fat_offset = cpu_to_le32(finfo.fat_byte_off / bd->sector_size);
@@ -235,9 +235,9 @@ static int write_fat_entry(int fd, __le32 clu,
                unsigned long long offset)
 {
        int nbyte;
                unsigned long long offset)
 {
        int nbyte;
+       off_t fat_entry_offset = finfo.fat_byte_off + (offset * sizeof(__le32));
 
 
-       lseek(fd, finfo.fat_byte_off + (offset * sizeof(__le32)), SEEK_SET);
-       nbyte = write(fd, (__u8 *) &clu, sizeof(__le32));
+       nbyte = pwrite(fd, (__u8 *) &clu, sizeof(__le32), fat_entry_offset);
        if (nbyte != sizeof(int)) {
                exfat_err("write failed, offset : %llu, clu : %x\n",
                        offset, clu);
        if (nbyte != sizeof(int)) {
                exfat_err("write failed, offset : %llu, clu : %x\n",
                        offset, clu);
@@ -321,8 +321,7 @@ static int exfat_create_bitmap(struct exfat_blk_dev *bd)
        for (i = 0; i < finfo.used_clu_cnt - EXFAT_FIRST_CLUSTER; i++)
                exfat_set_bit(bd, bitmap, i);
 
        for (i = 0; i < finfo.used_clu_cnt - EXFAT_FIRST_CLUSTER; i++)
                exfat_set_bit(bd, bitmap, i);
 
-       lseek(bd->dev_fd, finfo.bitmap_byte_off, SEEK_SET);
-       nbytes = write(bd->dev_fd, bitmap, finfo.bitmap_byte_len);
+       nbytes = pwrite(bd->dev_fd, bitmap, finfo.bitmap_byte_len, finfo.bitmap_byte_off);
        if (nbytes != finfo.bitmap_byte_len) {
                exfat_err("write failed, nbytes : %d, bitmap_len : %d\n",
                        nbytes, finfo.bitmap_byte_len);
        if (nbytes != finfo.bitmap_byte_len) {
                exfat_err("write failed, nbytes : %d, bitmap_len : %d\n",
                        nbytes, finfo.bitmap_byte_len);
@@ -359,8 +358,7 @@ static int exfat_create_root_dir(struct exfat_blk_dev *bd,
        ed[2].upcase_start_clu = cpu_to_le32(finfo.ut_start_clu);
        ed[2].upcase_size = cpu_to_le64(EXFAT_UPCASE_TABLE_SIZE);
 
        ed[2].upcase_start_clu = cpu_to_le32(finfo.ut_start_clu);
        ed[2].upcase_size = cpu_to_le64(EXFAT_UPCASE_TABLE_SIZE);
 
-       lseek(bd->dev_fd, finfo.root_byte_off, SEEK_SET);
-       nbytes = write(bd->dev_fd, ed, dentries_len);
+       nbytes = pwrite(bd->dev_fd, ed, dentries_len, finfo.root_byte_off);
        if (nbytes != dentries_len) {
                exfat_err("write failed, nbytes : %d, dentries_len : %d\n",
                        nbytes, dentries_len);
        if (nbytes != dentries_len) {
                exfat_err("write failed, nbytes : %d, dentries_len : %d\n",
                        nbytes, dentries_len);
@@ -440,6 +438,11 @@ static int exfat_build_mkfs_info(struct exfat_blk_dev *bd,
        unsigned long long total_clu_cnt;
        int clu_len;
 
        unsigned long long total_clu_cnt;
        int clu_len;
 
+       if (ui->cluster_size < bd->sector_size) {
+               exfat_err("cluster size (%u bytes) is smaller than sector size (%u bytes)\n",
+                         ui->cluster_size, bd->sector_size);
+               return -1;
+       }
        if (ui->boundary_align < bd->sector_size) {
                exfat_err("boundary alignment is too small (min %d)\n",
                                bd->sector_size);
        if (ui->boundary_align < bd->sector_size) {
                exfat_err("boundary alignment is too small (min %d)\n",
                                bd->sector_size);
@@ -447,8 +450,12 @@ static int exfat_build_mkfs_info(struct exfat_blk_dev *bd,
        }
        finfo.fat_byte_off = round_up(bd->offset + 24 * bd->sector_size,
                        ui->boundary_align) - bd->offset;
        }
        finfo.fat_byte_off = round_up(bd->offset + 24 * bd->sector_size,
                        ui->boundary_align) - bd->offset;
-       finfo.fat_byte_len = round_up((bd->num_clusters * sizeof(int)),
-               ui->cluster_size);
+       /* Prevent integer overflow when computing the FAT length */
+       if (bd->num_clusters > UINT32_MAX / 4) {
+               exfat_err("cluster size (%u bytes) is too small\n", ui->cluster_size);
+               return -1;
+       }
+       finfo.fat_byte_len = round_up((bd->num_clusters * 4), ui->cluster_size);
        finfo.clu_byte_off = round_up(bd->offset + finfo.fat_byte_off +
                finfo.fat_byte_len, ui->boundary_align) - bd->offset;
        if (bd->size <= finfo.clu_byte_off) {
        finfo.clu_byte_off = round_up(bd->offset + finfo.fat_byte_off +
                finfo.fat_byte_len, ui->boundary_align) - bd->offset;
        if (bd->size <= finfo.clu_byte_off) {
index 8d5ef1a7fc1f520d7bde6b106182a18c9160dcb3..f86fa237f0da0972228919c9eb6de2ba11c0eed2 100644 (file)
@@ -506,8 +506,7 @@ int exfat_create_upcase_table(struct exfat_blk_dev *bd)
 {
        int nbytes;
 
 {
        int nbytes;
 
-       lseek(bd->dev_fd, finfo.ut_byte_off, SEEK_SET);
-       nbytes = write(bd->dev_fd, upcase_table, EXFAT_UPCASE_TABLE_SIZE);
+       nbytes = pwrite(bd->dev_fd, upcase_table, EXFAT_UPCASE_TABLE_SIZE, finfo.ut_byte_off);
        if (nbytes != EXFAT_UPCASE_TABLE_SIZE)
                return -1;
 
        if (nbytes != EXFAT_UPCASE_TABLE_SIZE)
                return -1;