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

Regression: PNG which parsed in 0.16 fails to parse in 0.17 #337

Closed
Follpvosten opened this issue Feb 23, 2022 · 9 comments · Fixed by #338
Closed

Regression: PNG which parsed in 0.16 fails to parse in 0.17 #337

Follpvosten opened this issue Feb 23, 2022 · 9 comments · Fixed by #338

Comments

@Follpvosten
Copy link

During QA testing this issue came up.
I have a full example which reproduces it here: https://github.com/Follpvosten/png-parse-regression
Basically, the standard example from the docs used to decode this PNG fine. In 0.17, it doesn't work anymore.
The example I wrote has two tests which confirm that.

I have other example files which fail to parse if that's useful, and if I can do anything else to help with this issue, please let me know.
We won't be able to use 0.17 (and thus image 0.24) in production until this is fixed.

@HeroicKatora
Copy link
Member

HeroicKatora commented Feb 23, 2022

Issue being that tEXT chunk is now being decoded, but this decoding is broken when the chunk is larger than 32kB (which it appears to be in a photoshop export). The fix somewhere in the stream state machine:

https://github.com/image-rs/image-png/blob/master/src/decoder/stream.rs#L628-L640

This discards some of the head of a chunk larger than that constant (see CHUNCK_BUFFER_SIZE with appropriate comment). For deflate encoded data this is correct, we do not want to buffer it unecessarily. We may want to introduce a different method state for reading of other chunks. (Of course with appropriate guards against unbounded allocation).

@Follpvosten
Copy link
Author

Is there a way to opt out of the tEXT decoding entirely for now, perhaps to just turn off that feature if you don't need it?

@HeroicKatora
Copy link
Member

I'm afraid not. I'll have a fix soon and in the long term this makes sense. Can I utilize the provided image as a regression test, provided that I'll be replacing the pixel data with some dummy chunk? Otherwise a synthetic one will also do but real world data is always better.

@Follpvosten
Copy link
Author

Please do so!
I got this specific file from here: https://www.patreon.com/posts/34824025
Maybe you can get more test data from there; other files from that zip also caused this issue.

@HeroicKatora
Copy link
Member

HeroicKatora commented Feb 24, 2022

That means you do have any authority to permit this? I'm certainly not adding files with unclear copyright/licensing status to the repository. The good news is that with #338 applied all files in that archive pass:

OK: Advanced Shuttle.png (216x216, 8-bit RGB+alpha, non-interlaced, 80.5%)
OK: Airlock.png (109x109, 8-bit RGB+alpha, non-interlaced, 79.8%)
OK: Asteroid 1.png (73x73, 8-bit RGB+alpha, non-interlaced, 65.7%)
OK: Asteroid 2.png (69x69, 8-bit RGB+alpha, non-interlaced, 64.8%)
OK: Asteroid 3.png (59x59, 8-bit RGB+alpha, non-interlaced, 65.3%)
OK: Asteroid 4.png (79x79, 8-bit RGB+alpha, non-interlaced, 73.9%)
OK: Asteroid 5.png (76x76, 8-bit RGB+alpha, non-interlaced, 67.5%)
OK: Asteroid 6.png (67x67, 8-bit RGB+alpha, non-interlaced, 68.1%)
OK: Buggy.png (98x98, 8-bit RGB+alpha, non-interlaced, 76.0%)
OK: Corridoor.png (109x109, 8-bit RGB+alpha, non-interlaced, 74.6%)
OK: Crater 1.png (164x164, 8-bit RGB+alpha, non-interlaced, 80.7%)
OK: Crater 2.png (93x93, 8-bit RGB+alpha, non-interlaced, 69.6%)
OK: Crater 3.png (92x92, 8-bit RGB+alpha, non-interlaced, 72.1%)
OK: Crater 4.png (60x60, 8-bit RGB+alpha, non-interlaced, 68.0%)
OK: Crater 5.png (321x321, 8-bit RGB+alpha, non-interlaced, 85.6%)
OK: Floor Markings 0.png (31x31, 8-bit RGB+alpha, non-interlaced, 79.3%)
OK: Floor Markings 1.png (30x30, 8-bit RGB+alpha, non-interlaced, 88.6%)
OK: Floor Markings 2.png (30x30, 8-bit RGB+alpha, non-interlaced, 80.0%)
OK: Floor Markings 3.png (31x31, 8-bit RGB+alpha, non-interlaced, 83.2%)
OK: Floor Markings 4.png (30x30, 8-bit RGB+alpha, non-interlaced, 83.6%)
OK: Floor Markings 5.png (31x31, 8-bit RGB+alpha, non-interlaced, 85.1%)
OK: Floor Markings 6.png (31x31, 8-bit RGB+alpha, non-interlaced, 84.1%)
OK: Floor Markings 7.png (30x30, 8-bit RGB+alpha, non-interlaced, 88.4%)
OK: Floor Markings 8.png (31x31, 8-bit RGB+alpha, non-interlaced, 84.6%)
OK: Floor Markings 9.png (31x31, 8-bit RGB+alpha, non-interlaced, 84.1%)
OK: Floor Markings Red.png (226x226, 8-bit RGB+alpha, non-interlaced, 99.5%)
OK: Floor Markings White.png (226x226, 8-bit RGB+alpha, non-interlaced, 98.4%)
OK: Greenhouse Dome.png (162x162, 8-bit RGB+alpha, non-interlaced, 53.4%)
OK: Habitat 1.png (152x152, 8-bit RGB+alpha, non-interlaced, 69.7%)
OK: Habitat 2.png (152x152, 8-bit RGB+alpha, non-interlaced, 67.0%)
OK: Habitat 3.png (152x152, 8-bit RGB+alpha, non-interlaced, 57.5%)
OK: Habitat 4.png (151x151, 8-bit RGB+alpha, non-interlaced, 71.7%)
OK: Habitat 5.png (151x151, 8-bit RGB+alpha, non-interlaced, 54.7%)
OK: Ladder.png (36x36, 8-bit RGB+alpha, non-interlaced, 62.5%)
OK: Landing Platform.png (312x312, 8-bit RGB+alpha, non-interlaced, 87.2%)
OK: Landing Tower.png (344x344, 8-bit RGB+alpha, non-interlaced, 92.5%)
OK: Large Living Space Dome.png (364x364, 8-bit RGB+alpha, non-interlaced, 63.9%)
OK: Pipes 1.png (68x68, 8-bit RGB+alpha, non-interlaced, 77.5%)
OK: Pipes 2.png (47x47, 8-bit RGB+alpha, non-interlaced, 69.6%)
OK: Pipes 3.png (69x69, 8-bit RGB+alpha, non-interlaced, 86.7%)
OK: Pipes 4.png (69x69, 8-bit RGB+alpha, non-interlaced, 81.8%)
OK: Pipes 5.png (68x68, 8-bit RGB+alpha, non-interlaced, 82.5%)
OK: Rectangle Habitat.png (202x202, 8-bit RGB+alpha, non-interlaced, 87.5%)
OK: Rectangle Roof.png (202x202, 8-bit RGB+alpha, non-interlaced, 83.7%)
OK: Research Station.png (204x204, 8-bit RGB+alpha, non-interlaced, 82.6%)
OK: Rocks 10.png (11x11, 8-bit RGB+alpha, non-interlaced, 46.2%)
OK: Rocks 11.png (9x9, 8-bit RGB+alpha, non-interlaced, 58.3%)
OK: Rocks 12.png (14x14, 8-bit RGB+alpha, non-interlaced, 67.0%)
OK: Rocks 13.png (23x23, 8-bit RGB+alpha, non-interlaced, 54.9%)
OK: Rocks 14.png (18x18, 8-bit RGB+alpha, non-interlaced, 61.6%)
OK: Rocks 15.png (15x15, 8-bit RGB+alpha, non-interlaced, 48.1%)
OK: Rocks 16.png (15x15, 8-bit RGB+alpha, non-interlaced, 50.7%)
OK: Rocks 17.png (37x37, 8-bit RGB+alpha, non-interlaced, 52.7%)
OK: Rocks 18.png (10x10, 8-bit RGB+alpha, non-interlaced, 57.8%)
OK: Rocks 19.png (24x24, 8-bit RGB+alpha, non-interlaced, 66.2%)
OK: Rocks 1.png (60x60, 8-bit RGB+alpha, non-interlaced, 65.4%)
OK: Rocks 20.png (26x26, 8-bit RGB+alpha, non-interlaced, 78.4%)
OK: Rocks 21.png (44x44, 8-bit RGB+alpha, non-interlaced, 66.8%)
OK: Rocks 22.png (8x8, 8-bit RGB+alpha, non-interlaced, 49.4%)
OK: Rocks 23.png (15x15, 8-bit RGB+alpha, non-interlaced, 50.6%)
OK: Rocks 24.png (15x15, 8-bit RGB+alpha, non-interlaced, 48.4%)
OK: Rocks 25.png (33x33, 8-bit RGB+alpha, non-interlaced, 53.7%)
OK: Rocks 26.png (14x14, 8-bit RGB+alpha, non-interlaced, 61.4%)
OK: Rocks 2.png (29x29, 8-bit RGB+alpha, non-interlaced, 61.1%)
OK: Rocks 3.png (48x48, 8-bit RGB+alpha, non-interlaced, 59.0%)
OK: Rocks 4.png (14x14, 8-bit RGB+alpha, non-interlaced, 60.8%)
OK: Rocks 5.png (22x22, 8-bit RGB+alpha, non-interlaced, 57.5%)
OK: Rocks 6.png (29x29, 8-bit RGB+alpha, non-interlaced, 54.3%)
OK: Rocks 7.png (33x33, 8-bit RGB+alpha, non-interlaced, 57.0%)
OK: Rocks 8.png (25x25, 8-bit RGB+alpha, non-interlaced, 70.4%)
OK: Rocks 9.png (36x36, 8-bit RGB+alpha, non-interlaced, 72.3%)
OK: Round Roof.png (134x134, 8-bit RGB+alpha, non-interlaced, 50.2%)
OK: Satalite Dish.png (117x117, 8-bit RGB+alpha, non-interlaced, 71.1%)
OK: Shuttle.png (266x266, 8-bit RGB+alpha, non-interlaced, 88.6%)
OK: Solar Panel.png (56x56, 8-bit RGB+alpha, non-interlaced, 76.8%)
OK: Solar Panels.png (123x123, 8-bit RGB+alpha, non-interlaced, 73.2%)
OK: Tank 1.png (99x99, 8-bit RGB+alpha, non-interlaced, 66.6%)
OK: Tank 2.png (90x90, 8-bit RGB+alpha, non-interlaced, 61.7%)
OK: Upright Shuttle 2.png (176x176, 8-bit RGB+alpha, non-interlaced, 82.1%)
OK: Upright Shuttle.png (186x186, 8-bit RGB+alpha, non-interlaced, 75.5%)

@Follpvosten
Copy link
Author

That means you do have any authority to permit this?

Not necessarily - that account is one of our customers and we're using these files for QA testing. Our QA person said that they are free for non commercial use, but now that you mention it, I can't find a license either; I'll try to clear that up and report back.
I can definitely say though that if you replace the pixel data, nobody will complain about copyright.

@Follpvosten
Copy link
Author

Ok so I just found this: https://www.caeora.com/content-use
I think the Free License Agreement should apply to these as they're marked as "Free Tokens" in the banner image.
However that really doesn't clarify anything except for some very specific usecases.
Realistically I think the best approach would be to get hold of some person with Photoshop and have them export some files with similarily massive tEXT chunks.

@Follpvosten
Copy link
Author

Is there any chance for a minor release with this patch?
My project's main branch still depends on image 0.24, and I'd like to keep it that way.
If not, I'd have to patch the png dependency for now and hope that works out.

@HeroicKatora
Copy link
Member

@Follpvosten Quite likely, I'm just waiting to see if #333 will also land in time. Release likely within the next few days in any case. Remind me if not 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants