Обсуждение: [PATCH] readlink missing nul-termination in pg_rewind

Поиск
Список
Период
Сортировка

[PATCH] readlink missing nul-termination in pg_rewind

От
Abhijit Menon-Sen
Дата:
This is just something I noticed in passing. (I did a quick check of all
the other uses of readlink in the source, and they do get this right.)

-- Abhijit

P.S. Also in passing, I note that pg_rewind will follow links under any
directory anywhere named pg_tblspc (which probably doesn't matter), and
does not follow pg_xlog if it's a symlink (which probably does). If you
want, I can submit a trivial patch for the latter.

Вложения

Re: [PATCH] readlink missing nul-termination in pg_rewind

От
Tom Lane
Дата:
Abhijit Menon-Sen <ams@2ndQuadrant.com> writes:
> This is just something I noticed in passing. (I did a quick check of all
> the other uses of readlink in the source, and they do get this right.)

There's more random inconsistency than just this.  I think we should
standardize on the coding exhibited at, eg, basebackup.c:1023ff, which
positively ensures that it won't scribble on random memory if the
call returns an unexpected value.  Will fix.
        regards, tom lane



Re: [PATCH] readlink missing nul-termination in pg_rewind

От
Tom Lane
Дата:
Abhijit Menon-Sen <ams@2ndQuadrant.com> writes:
> P.S. Also in passing, I note that pg_rewind will follow links under any
> directory anywhere named pg_tblspc (which probably doesn't matter), and
> does not follow pg_xlog if it's a symlink (which probably does). If you
> want, I can submit a trivial patch for the latter.

As far as that goes, I think it does look at the whole parentpath, which
means it would not be fooled by sub-subdirectories named pg_tblspc.
A bigger problem is that whoever coded this forgot that parentpath could
be null, which I blame on the lack of an API specification for the
function.
        regards, tom lane



Re: [PATCH] readlink missing nul-termination in pg_rewind

От
Michael Paquier
Дата:
On Fri, May 29, 2015 at 1:46 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Abhijit Menon-Sen <ams@2ndQuadrant.com> writes:
>> P.S. Also in passing, I note that pg_rewind will follow links under any
>> directory anywhere named pg_tblspc (which probably doesn't matter), and
>> does not follow pg_xlog if it's a symlink (which probably does). If you
>> want, I can submit a trivial patch for the latter.
>
> As far as that goes, I think it does look at the whole parentpath, which
> means it would not be fooled by sub-subdirectories named pg_tblspc.
> A bigger problem is that whoever coded this forgot that parentpath could
> be null, which I blame on the lack of an API specification for the
> function.

Oh, thanks for pushing a fix for that. It was missed during the review...
-- 
Michael