From f1fe7d6bd7cfcae287acd7ebbd8e58767d9b3e0b Mon Sep 17 00:00:00 2001 From: PartialVolume <22084881+PartialVolume@users.noreply.github.com> Date: Fri, 29 Sep 2023 21:05:31 +0100 Subject: [PATCH] Fix intermittent segfault when --logfile specified Under the following conditions a segfault will occur upon starting nwipe. Run nwipe with --logfile option AND run nwipe in a directory that does not have write permissions so the logfile can't be created AND run nwipe without sudo or root or as as a user without sufficient privileges so you don't have permissions to write to the directory. --- src/logging.c | 1 - src/nwipe.c | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/logging.c b/src/logging.c index 4438d05e..07fe040f 100644 --- a/src/logging.c +++ b/src/logging.c @@ -401,7 +401,6 @@ void nwipe_log( nwipe_log_t level, const char* format, ... ) } user_abort = 1; terminate_signal = 1; - return; } } diff --git a/src/nwipe.c b/src/nwipe.c index e2242f1b..cc5419b4 100644 --- a/src/nwipe.c +++ b/src/nwipe.c @@ -185,8 +185,10 @@ int main( int argc, char** argv ) nwipe_enumerated = nwipe_device_get( &c1, argv, argc ); if( nwipe_enumerated == 0 ) { - nwipe_log( NWIPE_LOG_ERROR, "Devices not found. Check you're not excluding drives unnecessarily." ); - printf( "No drives found\n" ); + nwipe_log( NWIPE_LOG_ERROR, "Devices not found. Check you're not excluding drives unnecessarily," ); + nwipe_log( NWIPE_LOG_ERROR, "and you are running nwipe as sudo or as root." ); + printf( "Devices not found, check you're not excluding drives unnecessarily \n and you are running nwipe " + "as sudo or as root." ); cleanup(); exit( 1 ); }