Re: pgsql: Add missing string terminator - Mailing list pgsql-committers

From Daniel Gustafsson
Subject Re: pgsql: Add missing string terminator
Date
Msg-id 9887D3A8-A74F-4836-BC57-74AC4AE901BB@yesql.se
Whole thread Raw
In response to Re: pgsql: Add missing string terminator  (David Rowley <dgrowleyml@gmail.com>)
Responses Re: pgsql: Add missing string terminator
List pgsql-committers
> On 30 Apr 2025, at 12:57, David Rowley <dgrowleyml@gmail.com> wrote:
> 
> On Wed, 30 Apr 2025 at 21:36, Daniel Gustafsson
> <dgustafsson@postgresql.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




pgsql-committers by date:

Previous
From: David Rowley
Date:
Subject: Re: pgsql: Add missing string terminator
Next
From: David Rowley
Date:
Subject: Re: pgsql: Add missing string terminator