diff options
author | Xiaogang Cui <xiaogang@codeaurora.org> | 2013-10-23 16:49:14 +0800 |
---|---|---|
committer | Adnan Begovic <adnan@cyngn.com> | 2015-10-07 17:39:54 -0700 |
commit | 45a5a8bd40065bb0989541252bcca1119e1edb6f (patch) | |
tree | 331ff416a63c4c07bf6ecf962cc7eee3a9e05bcf | |
parent | 0a594ebe91ee23985715263efccc13e5ec8eb8b4 (diff) | |
download | android_external_fsck_msdos-45a5a8bd40065bb0989541252bcca1119e1edb6f.tar.gz android_external_fsck_msdos-45a5a8bd40065bb0989541252bcca1119e1edb6f.tar.bz2 android_external_fsck_msdos-45a5a8bd40065bb0989541252bcca1119e1edb6f.zip |
Fix crash in checklost
Fix crash in checklost , due to reuse pointer after free.
Change-Id: Ieab784219f63a1c4fabf838c4819c9452b058a03
-rw-r--r-- | fat.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -910,7 +910,7 @@ checklost(int dosfs, struct bootblock *boot) { int mod = FSOK; int ret; - struct cluster_chain_descriptor *fat ; + struct cluster_chain_descriptor *fat, *next; fat = RB_MIN(FSCK_MSDOS_CACHE,&rb_root); if(!fat){ fsck_info("%s:rb_root tree is empty\n",__func__); @@ -931,14 +931,18 @@ checklost(int dosfs, struct bootblock *boot) /* If the reconnect failed, then just clear the chain */ pwarn("Error reconnecting chain - clearing\n"); mod &= ~FSFATAL; + next = RB_NEXT(FSCK_MSDOS_CACHE,0,fat); clearchain(boot,fat,fat->head); mod |= FSFATMOD; - fat = RB_NEXT(FSCK_MSDOS_CACHE,0,fat); + fat = next; continue; } if (ret == FSERROR && ask(1, "Clear")) { + next = RB_NEXT(FSCK_MSDOS_CACHE,0,fat); clearchain(boot, fat, fat->head); mod |= FSFATMOD; + fat = next; + continue; } fat = RB_NEXT(FSCK_MSDOS_CACHE,0,fat); } |