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

Commitb9b6105

Browse files
committed
Fix ancient violation of zlib's API spec.
contrib/pgcrypto mishandled the case where deflate() does not consumeall of the offered input on the first try. It reset the next_in pointerto the start of the input instead of leaving it alone, causing the wrongdata to be fed to the next deflate() call.This has been broken since pgcrypto was committed. The reason for thelack of complaints seems to be that it's fairly hard to get stock zlibto not consume all the input, so long as the output buffer is big enough(which it normally would be in pgcrypto's usage; AFAICT the input isalways going to be packetized into packets no larger than ZIP_OUT_BUF).However, IBM's zlibNX implementation for AIX evidently will do itin some cases.I did not add a test case for this, because I couldn't find one thatwould fail with stock zlib. When we put back the test case forbug #16476, that will cover the zlibNX situation well enough.While here, write deflate()'s second argument as Z_NO_FLUSH per itsAPI spec, instead of hard-wiring the value zero.Per buildfarm results and subsequent investigation.Discussion:https://postgr.es/m/16476-692ef7b84e5fb893@postgresql.org
1 parent5733fa0 commitb9b6105

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

‎contrib/pgcrypto/pgp-compress.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ compress_process(PushFilter *next, void *priv, const uint8 *data, int len)
114114
/*
115115
* process data
116116
*/
117-
while (len>0)
117+
st->stream.next_in=unconstify(uint8*,data);
118+
st->stream.avail_in=len;
119+
while (st->stream.avail_in>0)
118120
{
119-
st->stream.next_in=unconstify(uint8*,data);
120-
st->stream.avail_in=len;
121121
st->stream.next_out=st->buf;
122122
st->stream.avail_out=st->buf_len;
123-
res=deflate(&st->stream,0);
123+
res=deflate(&st->stream,Z_NO_FLUSH);
124124
if (res!=Z_OK)
125125
returnPXE_PGP_COMPRESSION_ERROR;
126126

@@ -131,7 +131,6 @@ compress_process(PushFilter *next, void *priv, const uint8 *data, int len)
131131
if (res<0)
132132
returnres;
133133
}
134-
len=st->stream.avail_in;
135134
}
136135

137136
return0;
@@ -154,6 +153,7 @@ compress_flush(PushFilter *next, void *priv)
154153
zres=deflate(&st->stream,Z_FINISH);
155154
if (zres!=Z_STREAM_END&&zres!=Z_OK)
156155
returnPXE_PGP_COMPRESSION_ERROR;
156+
157157
n_out=st->buf_len-st->stream.avail_out;
158158
if (n_out>0)
159159
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp