Skip to content

Commit

Permalink
Rejected zero-sized runs
Browse files Browse the repository at this point in the history
A zero-size run is the universal way to indentify the end of a runlist,
so we must reject zero-sized runs when decompressing a runlist. A
zero-size data run is an error, and a zero-size hole is simply ignored.
  • Loading branch information
jpandre committed Sep 14, 2022
1 parent 875a1d4 commit 18bfc67
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions libntfs-3g/runlist.c
Expand Up @@ -5,7 +5,7 @@
* Copyright (c) 2002-2005 Richard Russon
* Copyright (c) 2002-2008 Szabolcs Szakacsits
* Copyright (c) 2004 Yura Pakhuchiy
* Copyright (c) 2007-2010 Jean-Pierre Andre
* Copyright (c) 2007-2022 Jean-Pierre Andre
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
Expand Down Expand Up @@ -918,11 +918,18 @@ static runlist_element *ntfs_mapping_pairs_decompress_i(const ntfs_volume *vol,
"array.\n");
goto err_out;
}
/* chkdsk accepts zero-sized runs only for holes */
if ((lcn != (LCN)-1) && !rl[rlpos].length) {
ntfs_log_debug(
"Invalid zero-sized data run.\n");
goto err_out;
}
/* Enter the current lcn into the runlist element. */
rl[rlpos].lcn = lcn;
}
/* Get to the next runlist element. */
rlpos++;
/* Get to the next runlist element, skipping zero-sized holes */
if (rl[rlpos].length)
rlpos++;
/* Increment the buffer position to the next mapping pair. */
buf += (*buf & 0xf) + ((*buf >> 4) & 0xf) + 1;
}
Expand Down

0 comments on commit 18bfc67

Please sign in to comment.