Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a few uses of DeflateStream.Read #1707

Merged
merged 2 commits into from
Jul 19, 2021

Conversation

stephentoub
Copy link
Contributor

@stephentoub stephentoub commented Jul 19, 2021

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)
    (68 of the 71 existing PngDecoder tests already fail when run against master, before and after this change, and I'm not sure if that's expected... presumably not? Maybe I'm just doing something wrong? I'm running them in test explorer in VS2022.)

Description

The code is assuming Stream.Read always returns the requested number of bytes unless it hits EOF, but that's not guaranteed; the Stream.Read contract only guarantees at least 1 byte will be returned until EOF even if more are requested.

Fixes #1704
dotnet/runtime#55866

The code is assuming it'll always return the requested amount unless it hits EOF, but that's not guaranteed.
@CLAassistant
Copy link

CLAassistant commented Jul 19, 2021

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Jul 19, 2021

Codecov Report

Merging #1707 (e3e2785) into master (61b137d) will increase coverage by 0.00%.
The diff coverage is 75.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1707   +/-   ##
=======================================
  Coverage   84.33%   84.33%           
=======================================
  Files         816      816           
  Lines       35914    35921    +7     
  Branches     4179     4183    +4     
=======================================
+ Hits        30288    30295    +7     
  Misses       4806     4806           
  Partials      820      820           
Flag Coverage Δ
unittests 84.33% <75.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/ImageSharp/Formats/Png/PngDecoderCore.cs 90.65% <60.00%> (+0.03%) ⬆️
...ompression/Decompressors/DeflateTiffCompression.cs 95.65% <100.00%> (+1.20%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 61b137d...e3e2785. Read the comment docs.

@JimBobSquarePants
Copy link
Member

Ah fantastic! Thanks @stephentoub

I'm not sure why you were getting test failures locally, (We have a few quirks in our setup (git submodules, LFS), were any specific errors being reported?

CI seems to be working well anyway, as does the test run on my machine.

@stephentoub
Copy link
Contributor Author

We have a few quirks in our setup (git submodules, LFS

Ah, I bet it's LFS. I'll try to fix it tomorrow. Thanks.

@JimBobSquarePants JimBobSquarePants merged commit 9baba86 into SixLabors:master Jul 19, 2021
@stephentoub stephentoub deleted the fixdsread branch July 19, 2021 10:32
@synercoder synercoder mentioned this pull request Sep 22, 2021
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Saving a PNG as Jpeg only processes a part of the image on .NET 6
3 participants