mirror of
https://github.com/martijnvanbrummelen/nwipe.git
synced 2026-02-20 13:42:14 +00:00
Merge pull request #527 from ggruber/SerialGarbage
fix: again garbage after serial number
This commit is contained in:
@@ -79,6 +79,9 @@ typedef struct nwipe_speedring_t_
|
|||||||
// Arbitrary length, so far most paths don't exceed about 25 characters
|
// Arbitrary length, so far most paths don't exceed about 25 characters
|
||||||
#define MAX_HWMON_PATH_LENGTH 100
|
#define MAX_HWMON_PATH_LENGTH 100
|
||||||
|
|
||||||
|
// 20 chracters for serial number plus null Byte
|
||||||
|
#define NWIPE_SERIALNUMBER_LENGTH 20
|
||||||
|
|
||||||
typedef struct nwipe_context_t_
|
typedef struct nwipe_context_t_
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -109,7 +112,8 @@ typedef struct nwipe_context_t_
|
|||||||
nwipe_device_t device_type; // Indicates an IDE, SCSI, or Compaq SMART device in enumerated form (int)
|
nwipe_device_t device_type; // Indicates an IDE, SCSI, or Compaq SMART device in enumerated form (int)
|
||||||
char device_type_str[14]; // Indicates an IDE, SCSI, USB etc as per nwipe_device_t but in ascii
|
char device_type_str[14]; // Indicates an IDE, SCSI, USB etc as per nwipe_device_t but in ascii
|
||||||
int device_is_ssd; // 0 = no SSD, 1 = is a SSD
|
int device_is_ssd; // 0 = no SSD, 1 = is a SSD
|
||||||
char device_serial_no[21]; // Serial number(processed, 20 characters plus null termination) of the device.
|
char device_serial_no[NWIPE_SERIALNUMBER_LENGTH
|
||||||
|
+ 1]; // Serial number(processed, 20 characters plus null termination) of the device.
|
||||||
int device_target; // The device target.
|
int device_target; // The device target.
|
||||||
|
|
||||||
u64 eta; // The estimated number of seconds until method completion.
|
u64 eta; // The estimated number of seconds until method completion.
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount )
|
|||||||
int fd;
|
int fd;
|
||||||
int idx;
|
int idx;
|
||||||
int r;
|
int r;
|
||||||
char tmp_serial[21];
|
char tmp_serial[NWIPE_SERIALNUMBER_LENGTH + 1];
|
||||||
nwipe_device_t bus;
|
nwipe_device_t bus;
|
||||||
int is_ssd;
|
int is_ssd;
|
||||||
int check_HPA; // a flag that indicates whether we check for a HPA on this device
|
int check_HPA; // a flag that indicates whether we check for a HPA on this device
|
||||||
@@ -252,7 +252,7 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount )
|
|||||||
ioctl( fd, HDIO_GET_IDENTITY, &next_device->identity );
|
ioctl( fd, HDIO_GET_IDENTITY, &next_device->identity );
|
||||||
close( fd );
|
close( fd );
|
||||||
|
|
||||||
for( idx = 0; idx < 20; idx++ )
|
for( idx = 0; idx < NWIPE_SERIALNUMBER_LENGTH; idx++ )
|
||||||
{
|
{
|
||||||
if( isascii( next_device->identity.serial_no[idx] ) && !iscntrl( next_device->identity.serial_no[idx] ) )
|
if( isascii( next_device->identity.serial_no[idx] ) && !iscntrl( next_device->identity.serial_no[idx] ) )
|
||||||
{
|
{
|
||||||
@@ -794,7 +794,8 @@ int nwipe_get_device_bus_type_and_serialno( char* device, nwipe_device_t* bus, i
|
|||||||
/* strip any leading or trailing spaces and left justify, +15 is the length of "Serial Number:" */
|
/* strip any leading or trailing spaces and left justify, +15 is the length of "Serial Number:" */
|
||||||
trim( &result[15] );
|
trim( &result[15] );
|
||||||
|
|
||||||
strncpy( serialnumber, &result[15], 20 );
|
strncpy( serialnumber, &result[15], NWIPE_SERIALNUMBER_LENGTH );
|
||||||
|
serialnumber[NWIPE_SERIALNUMBER_LENGTH] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( *bus == 0 )
|
if( *bus == 0 )
|
||||||
|
|||||||
@@ -666,7 +666,7 @@ void nwipe_log_summary( nwipe_context_t** ptr, int nwipe_selected )
|
|||||||
// char duration[5];
|
// char duration[5];
|
||||||
char duration[314];
|
char duration[314];
|
||||||
char model[18];
|
char model[18];
|
||||||
char serial_no[20];
|
char serial_no[NWIPE_SERIALNUMBER_LENGTH + 1];
|
||||||
char exclamation_flag[2];
|
char exclamation_flag[2];
|
||||||
int hours;
|
int hours;
|
||||||
int minutes;
|
int minutes;
|
||||||
@@ -875,7 +875,8 @@ void nwipe_log_summary( nwipe_context_t** ptr, int nwipe_selected )
|
|||||||
model[17] = 0;
|
model[17] = 0;
|
||||||
|
|
||||||
/* Serial No. */
|
/* Serial No. */
|
||||||
strncpy( serial_no, c[i]->device_serial_no, 20 );
|
strncpy( serial_no, c[i]->device_serial_no, NWIPE_SERIALNUMBER_LENGTH );
|
||||||
|
serial_no[NWIPE_SERIALNUMBER_LENGTH] = 0;
|
||||||
model[17] = 0;
|
model[17] = 0;
|
||||||
|
|
||||||
nwipe_log( NWIPE_LOG_NOTIMESTAMP,
|
nwipe_log( NWIPE_LOG_NOTIMESTAMP,
|
||||||
|
|||||||
Reference in New Issue
Block a user