提交 f0406481 编写于 作者: H Hannes Reinecke 提交者: Christoph Hellwig

nvmet: fixup buffer overrun in nvmet_subsys_attr_serial()

The serial number is copied into the buffer via memcpy_and_pad()
with the length NVMET_SN_MAX_SIZE. So when printing out we also
need to take just that length as anything beyond that will be
uninitialized.
Signed-off-by: NHannes Reinecke <hare@suse.de>
Signed-off-by: NChristoph Hellwig <hch@lst.de>
上级 ab7a2737
...@@ -1067,7 +1067,8 @@ static ssize_t nvmet_subsys_attr_serial_show(struct config_item *item, ...@@ -1067,7 +1067,8 @@ static ssize_t nvmet_subsys_attr_serial_show(struct config_item *item,
{ {
struct nvmet_subsys *subsys = to_subsys(item); struct nvmet_subsys *subsys = to_subsys(item);
return snprintf(page, PAGE_SIZE, "%s\n", subsys->serial); return snprintf(page, PAGE_SIZE, "%*s\n",
NVMET_SN_MAX_SIZE, subsys->serial);
} }
static ssize_t static ssize_t
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册