[PATCH 1/2] nvme: Ensure char members of struct nvme_id_ctrl are null-terminated

Keith Busch kbusch at kernel.org
Tue Jun 14 14:24:34 PDT 2022


On Tue, Jun 14, 2022 at 11:09:01PM +0200, Erwan Velu wrote:
> +	else {
> +		/* Ensure that model, serial and firmware fields are always null-terminated */
> +		(*id)->mn[sizeof((*id)->mn)-1] = 0;
> +		(*id)->sn[sizeof((*id)->sn)-1] = 0;
> +		(*id)->fr[sizeof((*id)->fr)-1] = 0;
> +	}

But the last byte here is owned by the controller. You may be truncating
information.



More information about the Linux-nvme mailing list