From 81fc4792391e4a1d7d87f9fb41bb4ee97445253b Mon Sep 17 00:00:00 2001 From: PartialVolume <22084881+PartialVolume@users.noreply.github.com> Date: Mon, 8 Apr 2024 21:17:41 +0100 Subject: [PATCH] Fix conditional jump on unitialised value This fixes a valgrind detected error. We check that the number of real max sectors is greater than zero before incrementing the value by 1. However ocassionaly the ioctl call may not be able to obtain the dco and therefore the ioctl data block is never populated. By zeroing the data block prior to use and if it is not populated by the ioctl call then the calculated real max sectors will be zero and no increment will occur which is what we want. --- src/hpa_dco.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hpa_dco.c b/src/hpa_dco.c index 160d4543..bbd3d1cd 100644 --- a/src/hpa_dco.c +++ b/src/hpa_dco.c @@ -722,6 +722,9 @@ u64 nwipe_read_dco_real_max_sectors( char* device ) unsigned char buffer[LBA_SIZE]; // Received data block unsigned char sense_buffer[SENSE_BUFFER_SIZE]; // Sense data + /* Zero the data block prior to use */ + memset( buffer, 0, LBA_SIZE ); + /* three characters represent one byte of sense data, i.e * two characters and a space "01 AE 67" */