Re: [PATCH V3] Fix buffer size warning for strcpy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 23.08.2021 16:35, Nigel Croxon wrote:
To meet requirements of Common Criteria certification vulnerability
assessment. Static code analysis has been run and found the following
error:
buffer_size_warning: Calling "strncpy" with a maximum size
argument of 16 bytes on destination array "ve->name" of
size 16 bytes might leave the destination string unterminated.


Yeah, please ignore my comment to v2- the task here it remove error, not
to acknowledge it.

+		int l = strlen(ve->name);
+		if (l > 16)
+			l = 16;
I think that whole "if" statement can be replaced by:
strnlen(ve->name, sizeof(ve->name))
+		memcpy(ve->name, name, l);
+	}




[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux