Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)
Richard Guo <guofenglinux@gmail.com>
From: Richard Guo <guofenglinux@gmail.com>
To: Ranier Vilela <ranier.vf@gmail.com>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2024-06-24T02:56:20Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Use safe string copy routine
- e930c872b65c 18.0 landed
On Mon, Jun 24, 2024 at 7:51 AM Ranier Vilela <ranier.vf@gmail.com> wrote: > In src/include/access/xlogbackup.h, the field *name* > has one byte extra to store null-termination. > > But, in the function *do_pg_backup_start*, > I think that is a mistake in the line (8736): > > memcpy(state->name, backupidstr, strlen(backupidstr)); > > memcpy with strlen does not copy the whole string. > strlen returns the exact length of the string, without > the null-termination. I noticed that the two callers of do_pg_backup_start both allocate BackupState with palloc0. Can we rely on this to ensure that the BackupState.name is initialized with null-termination? Thanks Richard