Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit76dd015

Browse files
committed
Improve more comments in astreamer_gzip.c.
Duplicate the comment from astreamer_plain_writer_new instead of justreferring to it. Add a further note to mention that there are dangersif anything else is written to the same FILE. Also add a comment wherewe dup() the filehandle, referring to the existing comment inastreamer_gzip_writer_finalize(), because the dup() looks wrong onfirst glance without that comment to clarify.Per concerns expressed by Tom Lane on pgsql-security, and usingsome wording suggested by him.Discussion:http://postgr.es/m/CA+TgmoYTFAD0YTh4HC1Nuhn0YEyoQi0_CENFgVzAY_YReiSksQ@mail.gmail.com
1 parentb8b3f86 commit76dd015

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

‎src/fe_utils/astreamer_gzip.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,16 @@ static const astreamer_ops astreamer_gzip_decompressor_ops = {
8686
* Create a astreamer that just compresses data using gzip, and then writes
8787
* it to a file.
8888
*
89-
* As in the case of astreamer_plain_writer_new, pathname is always used
90-
* for error reporting purposes; if file is NULL, it is also the opened and
91-
* closed so that the data may be written there.
89+
* The caller must specify a pathname and may specify a file. The pathname is
90+
* used for error-reporting purposes either way. If file is NULL, the pathname
91+
* also identifies the file to which the data should be written: it is opened
92+
* for writing and closed when done. If file is not NULL, the data is written
93+
* there.
94+
*
95+
* Note that zlib does not use the FILE interface, but operates directly on
96+
* a duplicate of the underlying fd. Hence, callers must take care if they
97+
* plan to write any other data to the same FILE, either before or after using
98+
* this.
9299
*/
93100
astreamer*
94101
astreamer_gzip_writer_new(char*pathname,FILE*file,
@@ -112,6 +119,10 @@ astreamer_gzip_writer_new(char *pathname, FILE *file,
112119
}
113120
else
114121
{
122+
/*
123+
* We must dup the file handle so that gzclose doesn't break the
124+
* caller's FILE. See comment for astreamer_gzip_writer_finalize.
125+
*/
115126
intfd=dup(fileno(file));
116127

117128
if (fd<0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp