summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2020-09-30 10:59:12 +0200
committerSimon Rettberg2020-09-30 10:59:12 +0200
commit75481cc3911866dbfb3ac0d3a1159b1c71d2e999 (patch)
tree2e0c9584705f4c06427179fa3510e8dc07121833
parentMake output block size customizable, default 1 byte (diff)
downloadntfsfree-75481cc3911866dbfb3ac0d3a1159b1c71d2e999.tar.gz
ntfsfree-75481cc3911866dbfb3ac0d3a1159b1c71d2e999.tar.xz
ntfsfree-75481cc3911866dbfb3ac0d3a1159b1c71d2e999.zip
Fix two (crash) bugs
- No device on cmdline - No proper bounds check when reading pagefile clusters
-rw-r--r--main.c7
1 files 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 <ntfs-3g/volume.h>
#include <ntfs-3g/dir.h>
-#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 <bytes>] [-h|--human-readable] [-b|--brief] [-p|--pagefile] [-s|--block-size <bytes>] <device>\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++;