[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] ui/console-vc: Silence warning about sprintf() on OpenBSD
From: |
Marc-André Lureau |
Subject: |
Re: [PATCH] ui/console-vc: Silence warning about sprintf() on OpenBSD |
Date: |
Tue, 15 Oct 2024 10:34:09 +0400 |
On Mon, Oct 14, 2024 at 7:10 PM Thomas Huth <thuth@redhat.com> wrote:
>
> The linker on OpenBSD complains:
>
> ld: warning: console-vc.c:824 (../src/ui/console-vc.c:824)([...]):
> warning: sprintf() is often misused, please use snprintf()
>
> Using snprintf() is certainly better here, so let's switch to that
> function instead.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> ui/console-vc.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/ui/console-vc.c b/ui/console-vc.c
> index 8393d532e7..336a1520eb 100644
> --- a/ui/console-vc.c
> +++ b/ui/console-vc.c
> @@ -821,9 +821,9 @@ static void vc_putchar(VCChardev *vc, int ch)
> break;
> case 6:
> /* report cursor position */
> - sprintf(response, "\033[%d;%dR",
> - (s->y_base + s->y) % s->total_height + 1,
> - s->x + 1);
> + snprintf(response, sizeof(response), "\033[%d;%dR",
> + (s->y_base + s->y) % s->total_height + 1,
> + s->x + 1);
> vc_respond_str(vc, response);
> break;
> }
> --
> 2.46.1
>