Re: Fix out-of-bounds in the function GetCommandTagName

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix out-of-bounds in the function GetCommandTagName
Date: 2024-04-14 23:38:09
Message-ID: CAApHDvqhEDo77c1PTtUcHr6bL7bqUBvo7YTRJo9TamEqTEYh9A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 15 Apr 2024 at 11:17, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> wrote:
> Coverity has reported some out-of-bounds bugs
> related to the GetCommandTagName function.
>
> The size of the array is defined by COMMAND_TAG_NEXTTAG enum,
> whose value currently corresponds to 193.
> Since enum items are evaluated starting at zero, by default.

I think the change makes sense. I don't see any good reason to define
COMMAND_TAG_NEXTTAG or force the compiler's hand when it comes to
sizing that array.

Clearly, Coverity does not understand that we'll never call any of
those GetCommandTag* functions with COMMAND_TAG_NEXTTAG.

> Patch attached.

You seem to have forgotten to attach it, but my comments above were
written with the assumption that the patch is what I've attached here.

David

Attachment Content-Type Size
get_rid_of_command_tag_nexttag.patch text/plain 800 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2024-04-14 23:41:38 meson and pg_config --libs/--ldflags_ex
Previous Message David Rowley 2024-04-14 23:20:16 Stability of queryid in minor versions