From e77164f710e68e1d0e8985ac50d381c9b1642fd3 Mon Sep 17 00:00:00 2001 From: Gerold Gruber Date: Sat, 4 Nov 2023 21:14:05 +0100 Subject: [PATCH] fix MAX_NUMBER_EXCLUDED_DRIVES, handle exceeding the limit, +README.md --- README.md | 2 +- src/device.c | 2 +- src/options.c | 7 +++++++ src/options.h | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2076d835..93915917 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ dmidecode provides SMBIOS/DMI host data to stdout or the log file. If you don't #### coreutils (provides readlink) [RECOMMENDED] readlink determines the bus type, i.e. ATA, USB etc. Without it the --nousb option won't work and bus type information will be missing from nwipes selection and wipe windows. The coreutils package is often automatically installed as default in most if not all distros. -#### smartmontools [RECOMMENDED] +#### smartmontools [REQUIRED] smartmontools obtains serial number information for supported USB to IDE/SATA adapters. Without it, drives plugged into USB ports will not show serial number information. If you want a quick and easy way to keep your copy of nwipe running the latest master release of nwipe see the [automating the download and compilation](#automating-the-download-and-compilation-process-for-debian-based-distros) section. diff --git a/src/device.c b/src/device.c index 7410c5f4..135343c2 100644 --- a/src/device.c +++ b/src/device.c @@ -140,7 +140,7 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount ) /* Check whether this drive is on the excluded drive list ? */ idx = 0; - while( idx < 10 ) + while( idx < MAX_NUMBER_EXCLUDED_DRIVES ) { if( !strcmp( dev->path, nwipe_options.exclude[idx++] ) ) { diff --git a/src/options.c b/src/options.c index b3113743..d145c9c8 100644 --- a/src/options.c +++ b/src/options.c @@ -439,6 +439,13 @@ int nwipe_options_parse( int argc, char** argv ) } } } + if( idx_drive == MAX_NUMBER_EXCLUDED_DRIVES ) + { + fprintf( + stderr, + "The number of excluded drives has reached the programs configured limit, aborting\n" ); + exit( 130 ); + } } break; diff --git a/src/options.h b/src/options.h index 40735851..96aeefc3 100644 --- a/src/options.h +++ b/src/options.h @@ -35,7 +35,7 @@ #define NWIPE_KNOB_SCSI "/proc/scsi/scsi" #define NWIPE_KNOB_SLEEP 1 #define NWIPE_KNOB_STAT "/proc/stat" -#define MAX_NUMBER_EXCLUDED_DRIVES 10 +#define MAX_NUMBER_EXCLUDED_DRIVES 32 #define MAX_DRIVE_PATH_LENGTH 200 // e.g. /dev/sda is only 8 characters long, so 200 should be plenty. #define DEFAULT_SYNC_RATE 100000 #define PATHNAME_MAX 2048