Re: refactoring basebackup.c (zstd workers)

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: refactoring basebackup.c (zstd workers)
Дата
Msg-id CA+TgmoZ1DbW_nKeVteVvYt0WvZDhm77_qdb-TErjctW+h5_3Jg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: refactoring basebackup.c (zstd workers)  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: refactoring basebackup.c (zstd workers)  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: refactoring basebackup.c (zstd workers)  (Justin Pryzby <pryzby@telsasoft.com>)
Список pgsql-hackers
On Sun, Mar 27, 2022 at 1:47 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Coverity has a nitpick about this:
>
> /srv/coverity/git/pgsql-git/postgresql/src/common/backup_compression.c: 194 in parse_bc_specification()
> 193                     /* Advance to next entry and loop around. */
> >>>     CID 1503251:  Null pointer dereferences  (REVERSE_INULL)
> >>>     Null-checking "vend" suggests that it may be null, but it has already been dereferenced on all paths leading
tothe check.
 
> 194                     specification = vend == NULL ? kwend + 1 : vend + 1;
> 195             }
> 196     }
>
> Not sure if you should remove this null-check or add some other ones,
> but I think you ought to do one or the other.

Yes, I think this is buggy.  I think there's only a theoretical bug
right now, because the only keyword we have is "level" and that
requires a value. But if I add an example keyword that does not
require an associated value (as demonstrated in the attached patch)
and do something like pg_basebackup -cfast -D whatever --compress
lz4:example, then the present code will dereference "vend" even though
it's NULL, which is not good. The attached patch also shows how I
think that should be fixed.

As I hope is apparent, the first hunk of this patch is not for commit,
and the second hunk is for commit.

-- 
Robert Haas
EDB: http://www.enterprisedb.com

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: CFBot has failures on 027_stream_regress for a number of patches
Следующее
От: Robert Haas
Дата:
Сообщение: Re: [PATCH v2] use has_privs_for_role for predefined roles