]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cros_ec: Add run-time check for input buffer overflow
authorSimon Glass <sjg@chromium.org>
Sat, 16 Jan 2021 21:52:24 +0000 (14:52 -0700)
committerSimon Glass <sjg@chromium.org>
Sat, 30 Jan 2021 21:25:41 +0000 (14:25 -0700)
This should not happen in normal operation, but the EC might have a bug,
so add a run-time check just in case.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/misc/cros_ec.c

index ce5fa5bee3546990417ecdbe778b59da6f2c82a3..e51ac874098433c3507efcff49cb8477e2fdcfee 100644 (file)
@@ -404,6 +404,8 @@ static int ec_command(struct udevice *dev, uint cmd, int cmd_version,
                 */
                if (din && in_buffer) {
                        assert(len <= din_len);
+                       if (len > din_len)
+                               return -ENOSPC;
                        memmove(din, in_buffer, len);
                }
        }