Thread (19 messages) 19 messages, 2 authors, 2021-02-10

Re: [PATCH V3 08/11] nvmet: use min of device_path and disk len

From: Christoph Hellwig <hch@lst.de>
Date: 2021-02-10 08:13:19

 static inline void __assign_req_name(char *name, struct nvmet_req *req)
 {
+	size_t len = min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path));
+
 	if (req->ns)
-		strncpy(name, req->ns->device_path, DISK_NAME_LEN);
+		strncpy(name, req->ns->device_path, len);
 	else
 		memset(name, 0, DISK_NAME_LEN);
This could dereference a NULL req->ns.  I've changed the patch
to eliminate the local variable and to return early for the NULL
req->ns case.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help