]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
NTFS: Fix two nasty runlist merging bugs that had gone unnoticed so far.
authorAnton Altaparmakov <aia21@cantab.net>
Thu, 8 Sep 2005 15:46:55 +0000 (16:46 +0100)
committerAnton Altaparmakov <aia21@cantab.net>
Thu, 8 Sep 2005 15:46:55 +0000 (16:46 +0100)
      Thanks to Stefano Picerno for the bug report.

Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
fs/ntfs/ChangeLog
fs/ntfs/runlist.c

index c5bbedff5ae5fc534c15d1df0bacafd0d051d8b9..4bc8f91c5fc016866e2665244b83856177f6f5ad 100644 (file)
@@ -43,6 +43,8 @@ ToDo/Notes:
        - Use ntfs_malloc_nofs_nofail() in the two critical regions in
          fs/ntfs/runlist.c::ntfs_runlists_merge().  This means we no longer
          need to panic() if the allocation fails as it now cannot fail.
+       - Fix two nasty runlist merging bugs that had gone unnoticed so far.
+         Thanks to Stefano Picerno for the bug report.
 
 2.1.23 - Implement extension of resident files and make writing safe as well as
         many bug fixes, cleanups, and enhancements...
index 3bb4a57d1fa901e0757693907d995b64a85d9988..d26a1be530c5f824c52e71320881612a2bd880df 100644 (file)
@@ -542,6 +542,7 @@ runlist_element *ntfs_runlists_merge(runlist_element *drl,
                        /* Scan to the end of the source runlist. */
                        for (dend = 0; likely(drl[dend].length); dend++)
                                ;
+                       dend++;
                        drl = ntfs_rl_realloc(drl, dend, dend + 1);
                        if (IS_ERR(drl))
                                return drl;
@@ -611,8 +612,8 @@ runlist_element *ntfs_runlists_merge(runlist_element *drl,
                 ((drl[dins].vcn + drl[dins].length) <=      /* End of hole   */
                  (srl[send - 1].vcn + srl[send - 1].length)));
 
-       /* Or we'll lose an end marker */
-       if (start && finish && (drl[dins].length == 0))
+       /* Or we will lose an end marker. */
+       if (finish && !drl[dins].length)
                ss++;
        if (marker && (drl[dins].vcn + drl[dins].length > srl[send - 1].vcn))
                finish = FALSE;