Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-07-02 Thread Ranier Vilela
Em ter., 2 de jul. de 2024 às 06:44, Daniel Gustafsson escreveu: > > On 2 Jul 2024, at 02:33, Michael Paquier wrote: > > > > On Mon, Jul 01, 2024 at 09:19:59PM +0200, Daniel Gustafsson wrote: > >>> The bit I don't understand about this discussion is what will happen > >>> with users that

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-07-02 Thread Daniel Gustafsson
> On 2 Jul 2024, at 02:33, Michael Paquier wrote: > > On Mon, Jul 01, 2024 at 09:19:59PM +0200, Daniel Gustafsson wrote: >>> The bit I don't understand about this discussion is what will happen >>> with users that currently have exactly 1024 chars in backup names today. >>> With this change,

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-07-01 Thread Michael Paquier
On Mon, Jul 01, 2024 at 09:19:59PM +0200, Daniel Gustafsson wrote: >> The bit I don't understand about this discussion is what will happen >> with users that currently have exactly 1024 chars in backup names today. >> With this change, we'll be truncating their names to 1023 chars instead. >> Why

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-07-01 Thread Daniel Gustafsson
> On 1 Jul 2024, at 21:58, Ranier Vilela wrote: > We only have to replace it with strlcpy. Thanks, I'll have a look at applying this in the tomorrow morning. -- Daniel Gustafsson

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-07-01 Thread Ranier Vilela
Em seg., 1 de jul. de 2024 às 16:20, Daniel Gustafsson escreveu: > > On 1 Jul 2024, at 21:15, Alvaro Herrera wrote: > > On 2024-Jul-01, Ranier Vilela wrote: > > >>> - charname[MAXPGPATH + 1]; > >>> + charname[MAXPGPATH];/* backup label name */ > >>> > >>>

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-07-01 Thread Ranier Vilela
Em seg., 1 de jul. de 2024 às 16:15, Alvaro Herrera escreveu: > On 2024-Jul-01, Ranier Vilela wrote: > > > > - charname[MAXPGPATH + 1]; > > > + charname[MAXPGPATH];/* backup label name */ > > > > > > With the introduced use of strlcpy, why do we need to change

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-07-01 Thread Daniel Gustafsson
> On 1 Jul 2024, at 21:15, Alvaro Herrera wrote: > On 2024-Jul-01, Ranier Vilela wrote: >>> - charname[MAXPGPATH + 1]; >>> + charname[MAXPGPATH];/* backup label name */ >>> >>> With the introduced use of strlcpy, why do we need to change this field? >>> >>

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-07-01 Thread Alvaro Herrera
On 2024-Jul-01, Ranier Vilela wrote: > > - charname[MAXPGPATH + 1]; > > + charname[MAXPGPATH];/* backup label name */ > > > > With the introduced use of strlcpy, why do we need to change this field? > > > The part about being the only reference in the entire

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-07-01 Thread Ranier Vilela
Em seg., 1 de jul. de 2024 às 14:35, Ranier Vilela escreveu: > Em seg., 1 de jul. de 2024 às 06:20, Daniel Gustafsson > escreveu: > >> > On 27 Jun 2024, at 13:50, Ranier Vilela wrote: >> >> > Now with file patch really attached. >> >> - if (strlen(backupidstr) > MAXPGPATH) >> + if

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-07-01 Thread Ranier Vilela
Em seg., 1 de jul. de 2024 às 06:20, Daniel Gustafsson escreveu: > > On 27 Jun 2024, at 13:50, Ranier Vilela wrote: > > > Now with file patch really attached. > > - if (strlen(backupidstr) > MAXPGPATH) > + if (strlcpy(state->name, backupidstr, sizeof(state->name)) >= >

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-07-01 Thread Daniel Gustafsson
> On 27 Jun 2024, at 13:50, Ranier Vilela wrote: > Now with file patch really attached. - if (strlen(backupidstr) > MAXPGPATH) + if (strlcpy(state->name, backupidstr, sizeof(state->name)) >= sizeof(state->name)) ereport(ERROR, Stylistic nit perhaps, I would keep

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-07-01 Thread Daniel Gustafsson
> On 27 Jun 2024, at 06:01, Yugo NAGATA wrote: >> Em dom., 23 de jun. de 2024 às 23:56, Richard Guo >> escreveu: >>> On Mon, Jun 24, 2024 at 7:51 AM Ranier Vilela wrote: memcpy with strlen does not copy the whole string. strlen returns the exact length of the string, without the

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-06-27 Thread Ranier Vilela
Em qui., 27 de jun. de 2024 às 08:48, Ranier Vilela escreveu: > Em qui., 27 de jun. de 2024 às 01:01, Yugo NAGATA > escreveu: > >> On Mon, 24 Jun 2024 08:25:36 -0300 >> Ranier Vilela wrote: >> >> > Em dom., 23 de jun. de 2024 às 23:56, Richard Guo < >> guofengli...@gmail.com> >> > escreveu: >>

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-06-27 Thread Ranier Vilela
Em qui., 27 de jun. de 2024 às 01:01, Yugo NAGATA escreveu: > On Mon, 24 Jun 2024 08:25:36 -0300 > Ranier Vilela wrote: > > > Em dom., 23 de jun. de 2024 às 23:56, Richard Guo < > guofengli...@gmail.com> > > escreveu: > > > > > On Mon, Jun 24, 2024 at 7:51 AM Ranier Vilela > wrote: > > > > In

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-06-26 Thread Michael Paquier
On Thu, Jun 27, 2024 at 12:17:04PM +0900, Yugo NAGATA wrote: > I don't think it is better to show a string longer than MAXPGPATH (=1024) > in the error message. +1. I am not convinced that this is useful in this context. -- Michael signature.asc Description: PGP signature

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-06-26 Thread Yugo NAGATA
On Mon, 24 Jun 2024 08:25:36 -0300 Ranier Vilela wrote: > Em dom., 23 de jun. de 2024 às 23:56, Richard Guo > escreveu: > > > On Mon, Jun 24, 2024 at 7:51 AM Ranier Vilela wrote: > > > In src/include/access/xlogbackup.h, the field *name* > > > has one byte extra to store null-termination. > >

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-06-26 Thread Yugo NAGATA
On Mon, 24 Jun 2024 08:37:26 -0300 Ranier Vilela wrote: > Em seg., 24 de jun. de 2024 às 00:27, Yugo NAGATA > escreveu: > > > On Sun, 23 Jun 2024 22:34:03 -0300 > > Ranier Vilela wrote: > > > > > Em dom., 23 de jun. de 2024 às 22:14, Ranier Vilela > > > > > escreveu: > > > > > > > Em dom.,

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-06-24 Thread Ranier Vilela
Em seg., 24 de jun. de 2024 às 00:27, Yugo NAGATA escreveu: > On Sun, 23 Jun 2024 22:34:03 -0300 > Ranier Vilela wrote: > > > Em dom., 23 de jun. de 2024 às 22:14, Ranier Vilela > > > escreveu: > > > > > Em dom., 23 de jun. de 2024 às 22:05, Ranier Vilela < > ranier...@gmail.com> > > >

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-06-24 Thread Ranier Vilela
Em dom., 23 de jun. de 2024 às 23:56, Richard Guo escreveu: > On Mon, Jun 24, 2024 at 7:51 AM Ranier Vilela 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

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-06-23 Thread Yugo NAGATA
On Sun, 23 Jun 2024 22:34:03 -0300 Ranier Vilela wrote: > Em dom., 23 de jun. de 2024 às 22:14, Ranier Vilela > escreveu: > > > Em dom., 23 de jun. de 2024 às 22:05, Ranier Vilela > > escreveu: > > > >> Em dom., 23 de jun. de 2024 às 21:54, Michael Paquier < > >> mich...@paquier.xyz>

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-06-23 Thread Richard Guo
On Mon, Jun 24, 2024 at 7:51 AM Ranier Vilela 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,

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-06-23 Thread Ranier Vilela
Em dom., 23 de jun. de 2024 às 22:14, Ranier Vilela escreveu: > Em dom., 23 de jun. de 2024 às 22:05, Ranier Vilela > escreveu: > >> Em dom., 23 de jun. de 2024 às 21:54, Michael Paquier < >> mich...@paquier.xyz> escreveu: >> >>> On Sun, Jun 23, 2024 at 09:34:45PM -0300, Ranier Vilela wrote:

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-06-23 Thread Ranier Vilela
Em dom., 23 de jun. de 2024 às 22:05, Ranier Vilela escreveu: > Em dom., 23 de jun. de 2024 às 21:54, Michael Paquier > escreveu: > >> On Sun, Jun 23, 2024 at 09:34:45PM -0300, Ranier Vilela wrote: >> > It's not critical code, so I think it's ok to use strlen, even because >> the >> > result of

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-06-23 Thread Ranier Vilela
Em dom., 23 de jun. de 2024 às 21:54, Michael Paquier escreveu: > On Sun, Jun 23, 2024 at 09:34:45PM -0300, Ranier Vilela wrote: > > It's not critical code, so I think it's ok to use strlen, even because > the > > result of strlen will already be available using modern compilers. > > > > So, I

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-06-23 Thread Michael Paquier
On Sun, Jun 23, 2024 at 09:34:45PM -0300, Ranier Vilela wrote: > It's not critical code, so I think it's ok to use strlen, even because the > result of strlen will already be available using modern compilers. > > So, I think it's ok to use memcpy with strlen + 1. It seems to me that there is a

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-06-23 Thread Ranier Vilela
Em dom., 23 de jun. de 2024 às 21:24, Michael Paquier escreveu: > On Sun, Jun 23, 2024 at 09:08:47PM -0300, Fabrízio de Royes Mello wrote: > > Doesn’t “sizeof” solve the problem? It take in account the > null-termination > > character. > > The size of BackupState->name is fixed with MAXPGPATH +

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-06-23 Thread Ranier Vilela
Em dom., 23 de jun. de 2024 às 21:08, Fabrízio de Royes Mello < fabriziome...@gmail.com> escreveu: > > On Sun, 23 Jun 2024 at 20:51 Ranier Vilela wrote: > >> Hi. >> >> In src/include/access/xlogbackup.h, the field *name* >> has one byte extra to store null-termination. >> >> But, in the function

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-06-23 Thread Michael Paquier
On Sun, Jun 23, 2024 at 09:08:47PM -0300, Fabrízio de Royes Mello wrote: > Doesn’t “sizeof” solve the problem? It take in account the null-termination > character. The size of BackupState->name is fixed with MAXPGPATH + 1, so it would be a better practice to use strlcpy() with sizeof(name)

Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-06-23 Thread Fabrízio de Royes Mello
On Sun, 23 Jun 2024 at 20:51 Ranier Vilela wrote: > Hi. > > 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,

Avoid incomplete copy string (src/backend/access/transam/xlog.c)

2024-06-23 Thread Ranier Vilela
Hi. 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