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

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

 



Hello Nigel,

-	memset(ve->name, ' ', 16);
+	memset(ve->name, '\0', sizeof(ve->name));
  	if (name)
-		strncpy(ve->name, name, 16);
+		memcpy(ve->name, name, strnlen(ve->name, sizeof(ve->name)));
  	ddf->virt->populated_vdes =
  		cpu_to_be16(be16_to_cpu(ddf->virt->populated_vdes)+1);

As I wrote under v3, you should use 'name' instead 've->name' in strnlen.
've->name' has length 0. You can also consider usage of memccpy.

Thanks,
Mariusz



[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