From 07a7c0ab0c7355cea7fd680c25cd4df33ecc7145 Mon Sep 17 00:00:00 2001 From: PartialVolume <22084881+PartialVolume@users.noreply.github.com> Date: Sat, 17 Feb 2024 17:00:37 +0000 Subject: [PATCH] Fix some strcpy compiler warnings Replace three strcpy commands with strncpy, bump minor version ready for more testing. --- configure.ac | 2 +- man/nwipe.1 | 2 +- src/device.c | 9 ++++++--- src/version.c | 6 +++--- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 3b8f011c..93a56411 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.63]) -AC_INIT([nwipe],[0.35],[git@brumit.nl]) +AC_INIT([nwipe],[0.35.9],[git@brumit.nl]) AM_INIT_AUTOMAKE(foreign subdir-objects) AC_CONFIG_FILES([Makefile src/Makefile man/Makefile]) AC_OUTPUT diff --git a/man/nwipe.1 b/man/nwipe.1 index 42f59af8..2b2145c2 100644 --- a/man/nwipe.1 +++ b/man/nwipe.1 @@ -1,4 +1,4 @@ -.TH NWIPE "24" "October 2023" "nwipe version 0.35" "User Commands" +.TH NWIPE "16" "February 2024" "nwipe version 0.35.9" "User Commands" .SH NAME nwipe \- securely erase disks .SH SYNOPSIS diff --git a/src/device.c b/src/device.c index 64129252..8475f301 100644 --- a/src/device.c +++ b/src/device.c @@ -283,7 +283,7 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount ) /* If the serial number hasn't already been populated */ if( next_device->device_serial_no[0] == 0 ) { - strcpy( next_device->device_serial_no, tmp_serial ); + strncpy( next_device->device_serial_no, tmp_serial, NWIPE_SERIALNUMBER_LENGTH ); } } @@ -292,13 +292,16 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount ) { if( next_device->device_serial_no[0] == 0 ) { - strcpy( next_device->device_serial_no, "???????????????" ); + strncpy( next_device->device_serial_no, "????????????????????", NWIPE_SERIALNUMBER_LENGTH + 1 ); } else { - strcpy( next_device->device_serial_no, "XXXXXXXXXXXXXXX" ); + strncpy( next_device->device_serial_no, "XXXXXXXXXXXXXXXXXXXX", NWIPE_SERIALNUMBER_LENGTH + 1 ); } } + /* strncpy would have copied the null terminator BUT just to be sure, just in case somebody changes the length + * of those strings we should explicitly terminate the string */ + next_device->device_serial_no[NWIPE_SERIALNUMBER_LENGTH] = 0; /* Initialise the variables that toggle the [size][temp c] with [HPA status] * Not currently used, but may be used in the future or for other purposes diff --git a/src/version.c b/src/version.c index 542d31ed..094b6a28 100644 --- a/src/version.c +++ b/src/version.c @@ -4,14 +4,14 @@ * used by configure to dynamically assign those values * to documentation files. */ -const char* version_string = "0.35.8"; +const char* version_string = "0.35.9"; const char* program_name = "nwipe"; const char* author_name = "Martijn van Brummelen"; const char* email_address = "git@brumit.nl"; -const char* years = "2023"; +const char* years = "2024"; const char* copyright = "Copyright Darik Horn \n\ Modifications to original dwipe Copyright Andy Beverley \n\ This is free software; see the source for copying conditions.\n\ There is NO warranty; not even for MERCHANTABILITY or FITNESS\n\ FOR A PARTICULAR PURPOSE.\n"; -const char* banner = "nwipe 0.35.8"; +const char* banner = "nwipe 0.35.9";