cros_ec: Add run-time check for input buffer overflow

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>
This commit is contained in:
Simon Glass committed 2021-01-30 14:25:41 -07:00
1 parent 2525e53c27
commit 698e30f7a8
1 file changed
+2
+2
View 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);
}
}