forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit3cac2c8
committed
Handle close() failures more robustly in pg_dump and pg_basebackup.
Coverity complained that applying get_gz_error after a failed gzclose,as we did in one place in pg_basebackup, is unsafe. I think it'sright: it's entirely likely that the call is touching freed memory.Change that to inspect errno, as we do for other gzclose calls.Also, be careful to initialize errno to zero immediately before anygzclose() call where we care about the error status. (There aresome calls where we don't, because we already failed at some previousstep.) This ensures that we don't get a misleadingly irrelevanterror code if gzclose() fails in a way that doesn't set errno.We could work harder at that, but it looks to me like all such casesare basically can't-happen if we're not misusing zlib, so it'snot worth the extra notational cruft that would be required.Also, fix several places that simply failed to check for close-timeerrors at all, mostly at some remove from the close or gzclose itself;and one place that did check but didn't bother to report the errno.Back-patch to v12. These mistakes are older than that, but betweenthe frontend logging API changes that happened in v12 and the factthat frontend code can't rely on %m before that, the patch would needsubstantial revision to work in older branches. It doesn't quiteseem worth the trouble given the lack of related field complaints.Patch by me; thanks to Michael Paquier for review.Discussion:https://postgr.es/m/1343113.1636489231@sss.pgh.pa.us1 parenta8d8445 commit3cac2c8
File tree
6 files changed
+24
-8
lines changed- src/bin
- pg_basebackup
- pg_dump
6 files changed
+24
-8
lines changedLines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
303 | 303 |
| |
304 | 304 |
| |
305 | 305 |
| |
| 306 | + | |
306 | 307 |
| |
307 | 308 |
| |
308 |
| - | |
309 |
| - | |
310 |
| - | |
| 309 | + | |
| 310 | + | |
311 | 311 |
| |
312 | 312 |
| |
313 | 313 |
| |
|
Lines changed: 6 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
70 | 70 |
| |
71 | 71 |
| |
72 | 72 |
| |
73 |
| - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
74 | 79 |
| |
75 | 80 |
| |
76 | 81 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
355 | 355 |
| |
356 | 356 |
| |
357 | 357 |
| |
| 358 | + | |
| 359 | + | |
358 | 360 |
| |
| 361 | + | |
359 | 362 |
| |
360 | 363 |
| |
361 | 364 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
268 | 268 |
| |
269 | 269 |
| |
270 | 270 |
| |
| 271 | + | |
271 | 272 |
| |
272 | 273 |
| |
273 | 274 |
| |
| |||
1567 | 1568 |
| |
1568 | 1569 |
| |
1569 | 1570 |
| |
| 1571 | + | |
1570 | 1572 |
| |
1571 | 1573 |
| |
1572 | 1574 |
| |
|
Lines changed: 6 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
369 | 369 |
| |
370 | 370 |
| |
371 | 371 |
| |
372 |
| - | |
| 372 | + | |
| 373 | + | |
373 | 374 |
| |
374 | 375 |
| |
375 | 376 |
| |
| |||
680 | 681 |
| |
681 | 682 |
| |
682 | 683 |
| |
683 |
| - | |
| 684 | + | |
| 685 | + | |
684 | 686 |
| |
685 | 687 |
| |
686 | 688 |
| |
| |||
699 | 701 |
| |
700 | 702 |
| |
701 | 703 |
| |
702 |
| - | |
| 704 | + | |
| 705 | + | |
703 | 706 |
| |
704 | 707 |
| |
705 | 708 |
| |
|
Lines changed: 4 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
438 | 438 |
| |
439 | 439 |
| |
440 | 440 |
| |
| 441 | + | |
| 442 | + | |
441 | 443 |
| |
442 |
| - | |
| 444 | + | |
| 445 | + | |
443 | 446 |
| |
444 | 447 |
| |
445 | 448 |
| |
|
0 commit comments
Comments
(0)