From 75481cc3911866dbfb3ac0d3a1159b1c71d2e999 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 30 Sep 2020 10:59:12 +0200 Subject: Fix two (crash) bugs - No device on cmdline - No proper bounds check when reading pagefile clusters --- main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index dd2912b..a90fbaa 100644 --- a/main.c +++ b/main.c @@ -9,7 +9,7 @@ #include #include -#define PFMAX (10) +#define PFMAX (100) static struct { s64 from; s64 to; @@ -99,6 +99,9 @@ static int parse_options(int argc, char **argv) } if (help) break; } + if (options.device == NULL) { + help = 1; + } if (help || options.min_size < 0 || options.output_block_size < 1) { ntfs_log_error("Usage: %s [-m|--min-size ] [-h|--human-readable] [-b|--brief] [-p|--pagefile] [-s|--block-size ] \n", argv[0]); @@ -412,7 +415,7 @@ static int get_pagefile_clusters(ntfs_volume *vol) if (rec->non_resident) { runs = ntfs_mapping_pairs_decompress(vol, rec, NULL); if (runs) { - for (i = 0; runs[i].length > 0; i++) { + for (i = 0; pfcount < PFMAX && runs[i].length > 0; i++) { pagefile[pfcount].from = runs[i].lcn; pagefile[pfcount].to = runs[i].lcn + (runs[i].length - 1); pfcount++; -- cgit v1.2.3-55-g7522