Re: pgsql: Add missing string terminator

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

> On 30 Apr 2025, at 12:57, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
>
> On Wed, 30 Apr 2025 at 21:36, Daniel Gustafsson
> <dgustafsson(at)postgresql(dot)org> wrote:
>> Add missing string terminator
>
> A possible minor niggle. Would memcpy not be a more suitable function
> for this?

How about using strlcpy as suggested by Peter?

- strncpy(nameptr, "Remaining Totals", namelen);
- nameptr[namelen] = '\0';
+ strlcpy(nameptr, "Remaining Totals", namelen + 1);

--
Daniel Gustafsson

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message David Rowley 2025-04-30 11:43:11 Re: pgsql: Add missing string terminator
Previous Message David Rowley 2025-04-30 10:57:56 Re: pgsql: Add missing string terminator