| From: | Daniel Gustafsson <daniel(at)yesql(dot)se> |
|---|---|
| To: | Evgeniy Gorbanev <gorbanyoves(at)basealt(dot)ru> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: No error checking when reading from file using zstd in pg_dump |
| Date: | 2025-06-16 08:25:43 |
| Message-ID: | C22FF2A1-783D-4334-998B-2D4432EFD7C5@yesql.se |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On 16 Jun 2025, at 10:14, Evgeniy Gorbanev <gorbanyoves(at)basealt(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Steven Niu | 2025-06-16 08:51:46 | Re: relrewrite not documented at the top of heap_create_with_catalog() |
| Previous Message | Evgeniy Gorbanev | 2025-06-16 08:14:36 | No error checking when reading from file using zstd in pg_dump |