[PATCH v3 01/13] serial: sandbox: Fix buffer underflow in puts
Sean Anderson
sean.anderson at seco.com
Tue May 31 16:43:06 CEST 2022
On 5/30/22 6:00 AM, Andrew Scull wrote:
> Fix the buffer underflow that would occur if puts is called with length
> of zero.
>
> Fixes: efa51f2bd64 ("serial: sandbox: Implement puts")
> Cc: Sean Anderson <sean.anderson at seco.com>
> Cc: Simon Glass <sjg at chromium.org>
> ---
> drivers/serial/sandbox.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c
> index e726e19c46..13b54921c4 100644
> --- a/drivers/serial/sandbox.c
> +++ b/drivers/serial/sandbox.c
> @@ -114,7 +114,7 @@ static ssize_t sandbox_serial_puts(struct udevice *dev, const char *s,
> struct sandbox_serial_priv *priv = dev_get_priv(dev);
> ssize_t ret;
>
> - if (s[len - 1] == '\n')
> + if (len && s[len - 1] == '\n')
> priv->start_of_line = true;
>
> if (sandbox_serial_enabled) {
>
Reviewed-by: Sean Anderson <sean.anderson at seco.com>
More information about the U-Boot
mailing list