diff options
author | Eugene Kliuchnikov <eustas.ru@gmail.com> | 2020-07-02 17:57:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-02 17:57:40 +0200 |
commit | 5519352661a948f91232b52ec2146c398020dbbe (patch) | |
tree | bbcc776e55407fb283a5812571c0dcf355ec69fb /c | |
parent | d2ea198232916f6894f4f36ea47458c6e56bc4e0 (diff) | |
download | brotli-5519352661a948f91232b52ec2146c398020dbbe.zip brotli-5519352661a948f91232b52ec2146c398020dbbe.tar.gz brotli-5519352661a948f91232b52ec2146c398020dbbe.tar.bz2 |
Add workaround for lying feof. (#814)
Should fix #812
Diffstat (limited to 'c')
-rw-r--r-- | c/tools/brotli.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/c/tools/brotli.c b/c/tools/brotli.c index 04606a8..3db34f2 100644 --- a/c/tools/brotli.c +++ b/c/tools/brotli.c @@ -803,6 +803,8 @@ static void InitializeBuffers(Context* context) { context->total_out = 0; } +/* This method might give the false-negative result. + However, after an empty / incomplete read it should tell the truth. */ static BROTLI_BOOL HasMoreInput(Context* context) { return feof(context->fin) ? BROTLI_FALSE : BROTLI_TRUE; } @@ -883,7 +885,9 @@ static BROTLI_BOOL DecompressFile(Context* context, BrotliDecoderState* s) { if (!ProvideOutput(context)) return BROTLI_FALSE; } else if (result == BROTLI_DECODER_RESULT_SUCCESS) { if (!FlushOutput(context)) return BROTLI_FALSE; - if (context->available_in != 0 || HasMoreInput(context)) { + int has_more_input = + (context->available_in != 0) || (fgetc(context->fin) != EOF); + if (has_more_input) { fprintf(stderr, "corrupt input [%s]\n", PrintablePath(context->current_input_path)); return BROTLI_FALSE; |