diff options
author | Simon Rettberg | 2020-09-30 10:59:12 +0200 |
---|---|---|
committer | Simon Rettberg | 2020-09-30 10:59:12 +0200 |
commit | 75481cc3911866dbfb3ac0d3a1159b1c71d2e999 (patch) | |
tree | 2e0c9584705f4c06427179fa3510e8dc07121833 | |
parent | Make output block size customizable, default 1 byte (diff) | |
download | ntfsfree-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.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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++; |