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

From: Keith Busch
Date: Tue Jun 14 2022 - 17:24:43 EST


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.