Re: pgsql: Add missing string terminator

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Add missing string terminator
Date: 2025-04-30 11:43:11
Message-ID: CAApHDvrEJeCPesmpeS24UAU8vanq9vKYZC6m1kTDFkxQQ2qTiw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On Wed, 30 Apr 2025 at 23:27, Daniel Gustafsson <daniel(at)yesql(dot)se> wrote:
> How about using strlcpy as suggested by Peter?
>
> - strncpy(nameptr, "Remaining Totals", namelen);
> - nameptr[namelen] = '\0';
> + strlcpy(nameptr, "Remaining Totals", namelen + 1);

Sorry, I only noticed that conversation afterwards. Yeah, strlcpy()
is fine too. memcpy() would make more sense IMO, since the length is
known already. I'm fine with either, however.

David

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message David Rowley 2025-04-30 11:56:08 Re: pgsql: Add missing string terminator
Previous Message Daniel Gustafsson 2025-04-30 11:27:18 Re: pgsql: Add missing string terminator