Skip to content

Commit

Permalink
Fix some strcpy compiler warnings
Browse files Browse the repository at this point in the history
Replace three strcpy commands with strncpy,
bump minor version ready for more testing.
  • Loading branch information
PartialVolume committed Feb 17, 2024
1 parent 2fae6ea commit 07a7c0a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.63])
AC_INIT([nwipe],[0.35],[[email protected]])
AC_INIT([nwipe],[0.35.9],[[email protected]])
AM_INIT_AUTOMAKE(foreign subdir-objects)
AC_CONFIG_FILES([Makefile src/Makefile man/Makefile])
AC_OUTPUT
Expand Down
2 changes: 1 addition & 1 deletion man/nwipe.1
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 6 additions & 3 deletions src/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}

Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]";
const char* years = "2023";
const char* years = "2024";
const char* copyright = "Copyright Darik Horn <[email protected]>\n\
Modifications to original dwipe Copyright Andy Beverley <[email protected]>\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";

0 comments on commit 07a7c0a

Please sign in to comment.