[smatch stuff] iscsi-target: string size issue in lio_target_call_addnptotpg()

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

 



Smatch complains about the string handling in lio_target_call_addnptotpg().

drivers/target/iscsi/iscsi_target_configfs.c +184 lio_target_call_addnptotpg(21)
	error: snprintf() chops off the last chars of 'name': 257 vs 256

   176          char buf[MAX_PORTAL_LEN + 1];

	buffer holds 257 chars.

   177  
   178          if (strlen(name) > MAX_PORTAL_LEN) {

	string is 256 chars plus NUL.  (257 chars).

   179                  pr_err("strlen(name): %d exceeds MAX_PORTAL_LEN: %d\n",
   180                          (int)strlen(name), MAX_PORTAL_LEN);
   181                  return ERR_PTR(-EOVERFLOW);
   182          }
   183          memset(buf, 0, MAX_PORTAL_LEN + 1);

	set 257 chars to NULL.

   184          snprintf(buf, MAX_PORTAL_LEN, "%s", name);

	Copy 255 chars and write a NUL char to the second last char
	in the buffer.  The last char is also NUL.

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux