pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Evgeniy Gorbanev <gorbanyoves@basealt.ru>
To: Daniel Gustafsson <daniel@yesql.se>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: No error checking when reading from file using zstd in pg_dump
Date: Mon, 16 Jun 2025 14:52:08 +0600
Message-ID: <95255a86-4bc7-4ff4-aa26-4441aafdf0fb@basealt.ru> (raw)
In-Reply-To: <C22FF2A1-783D-4334-998B-2D4432EFD7C5@yesql.se>
References: <6b9817a8-88ec-4efd-b441-9e2a0439c6b8@basealt.ru>
	<C22FF2A1-783D-4334-998B-2D4432EFD7C5@yesql.se>


16.06.2025 14:25, Daniel Gustafsson пишет:
>> On 16 Jun 2025, at 10:14, Evgeniy Gorbanev <gorbanyoves@basealt.ru> wrote:
>> In src/bin/pg_dump/compress_zstd.c, the Zstd_read function always
>> returns true. But if you look at the Zstd_gets and Zstd_getc functions,
>> where Zstd_read is called via CFH->read_func, it is expected that
>> the Zstd_read function can also return false. In case of
>> a read-from-file error, the process is expected to terminate, but
>> pg_dump will continue the process.
>> I assume that after checking
>> if (cnt == 0)
>> should be
>> return false;
>   	if (cnt == 0)
> -		break;
> +		return false;
>
> As cnt is coming from fread() returning false here would be wrong as you cannot
> from 0 alone know if it's EOF or an error.  Instead it needs to inspect the
> stream with feof() and ferror() to know how to proceed.
>
> --
> Daniel Gustafsson

The feof() check is in the calling functions, e.g. in the Zstd_getc
function.


Regards, Evgeniy






view thread (29+ messages)  latest in thread

Message-ID: <95255a86-4bc7-4ff4-aa26-4441aafdf0fb@basealt.ru>
Permalink:  ../95255a86-4bc7-4ff4-aa26-4441aafdf0fb@basealt.ru/
Also on:    postgresql.org/message-id/95255a86-4bc7-4ff4-aa26-4441aafdf0fb@basealt.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: gorbanyoves@basealt.ru, daniel@yesql.se, pgsql-hackers@lists.postgresql.org
  Subject: Re: No error checking when reading from file using zstd in pg_dump
  In-Reply-To: <95255a86-4bc7-4ff4-aa26-4441aafdf0fb@basealt.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox