media: sti: don't copy past the size
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 21 Jun 2021 07:32:25 +0000 (09:32 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 12 Jul 2021 07:16:31 +0000 (09:16 +0200)
commit54e80d9883bd5b76c80710bddc63d1bd3f374d50
tree25512fbf73c836c72d8be54e2a4494950d55ab95
parent8db11aebdb8f93f46a8513c22c9bd52fa23263aa
media: sti: don't copy past the size

The logic at delta_ipc_open() tries to copy past the size of
the name passed to it:

drivers/media/platform/sti/delta/delta-ipc.c:178 delta_ipc_open() error: __memcpy() 'name' too small (17 vs 32)

Basically,this function is called just one with:

ret = delta_ipc_open(pctx, "JPEG_DECODER_HW0", ...);

The string used there has just 17 bytes. Yet, the logic tries
to copy the entire name size (32 bytes), which is plain wrong.

Replace it by strscpy, which is good enough to copy the string,
warranting that this will be NUL-terminated.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/platform/sti/delta/delta-ipc.c