Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8035fa94 authored by Mayank Rana's avatar Mayank Rana
Browse files

usb: gadget: limit the input string size in fsg_show_file



Fix code quality issues found by the automatic checking tool.
Limit the input string size in fsg_show_file for safe usage of memmove

CRs-Fixed: 566927
Change-Id: I0feed4877c0d8075460e7dd75e01967a68ce9db3
Signed-off-by: default avatarDanny Segal <dsegal@codeaurora.org>
Signed-off-by: default avatarMaya Erez <merez@codeaurora.org>
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
parent 3380d16c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -376,6 +376,9 @@ ssize_t fsg_show_file(struct fsg_lun *curlun, struct rw_semaphore *filesem,
			rc = PTR_ERR(p);
		else {
			rc = strlen(p);
			if (rc > PAGE_SIZE - 2)
				rc = PAGE_SIZE - 2;

			memmove(buf, p, rc);
			buf[rc] = '\n';		/* Add a newline */
			buf[++rc] = 0;