Commit Graph

2157 Commits

Author SHA1 Message Date
Fabian Giesen
45eb4ac158 global: very basic .gitignore for object files 2023-12-14 03:13:59 -08:00
Fabian Giesen
e5f0e18d0f stb_image: Small PNG filter simplification
Paeth on the first scanline is not a separate filter, it
happens to be equivalent to the "sub" filter which is already
an option.
2023-12-14 03:13:59 -08:00
Fabian Giesen
d373674115 stb_image: Fix zlib decoder end-of-stream handling
We speculatively try to fill our bit buffer to always contain
at least 16 bits for stbi__zhuffman_decode. It's not a sign of
a malformed stream for us to be reading past the end there,
because the contents of that bit buffer are speculative; it's
only a malformed stream if we actually _consume_ the extra bits.

This fix adds some extra logic where we the first time we hit
zeof, we add an explicit 16 extra zero bits at the top of the
bit buffer just so that for the purposes of the decoder, we have
16 bits in the buffer.

However, if at the end of stream, we have the "hit zeof once"
flag set and less than 16 bits remaining in the bit buffer, we
know some of those implicit zero bits got read, which indicates
we actually had a past-end-of-stream read. In that case, flag
it as an error.

While I'm in here, also rephrase the length-too-large check to
not do any potentially-overflowing pointer arithmetic.

Fixes issue #1456.
2023-12-14 03:13:59 -08:00
Sean Barrett
03f50e343d security notice 2023-11-15 09:36:28 -08:00
Sean Barrett
1d878bd2a3 security notice 2023-11-15 09:35:21 -08:00
Sean Barrett
beebb24b94 README.md: fix reference to stb_image_resize2.h 2023-10-11 17:32:00 -07:00
Sean Barrett
e81f294b16 stb_image_resize: switch GNU/clang from "asm" to "__asm__" for -c99 compatibility 2023-10-11 17:28:56 -07:00
Sean Barrett
c4bbb6e75f stb_image_resize2.h 2.00 2023-10-09 17:23:04 -07:00
Sean Barrett
5736b15f7e re-add perlin noise again 2023-01-29 10:47:07 -08:00
Sean Barrett
3ecc60f25a add version history update for stb_image 2023-01-29 10:19:12 -08:00
Sean Barrett
6199bf7713 update stb_image to 2.28 2023-01-29 06:24:13 -08:00
Sean Barrett
7c14c47e2f Merge branch 'sean_image' 2023-01-29 06:19:13 -08:00
Sean Barrett
1891060782 a fix 2023-01-29 06:17:45 -08:00
Fabian Giesen
40eb865b3b stb_image: header scan mode always needs to check for tRNS
For paletted images, header-scanning mode (used by stbi_info) kept
going after the image header to see if a tRNS (transparency) chunk
shows up to correctly determine the channel count, but we would
immediately return after IHDR for non-paletted images.

This is incorrect. We also change our reported channel count on
RGB images with a tRNS chunk, therefore non-paletted images also
have to resume scanning further chunks.

Update the logic to keep scanning regardless and report the
correct channel count from stbi_info for RGB images with tRNS
(constant alpha channel).

Fixes issue #1419.
2023-01-23 00:46:33 -08:00
Fabian Giesen
24fa1ff2e9 stb_image: Fix broken indenting introduced earlier 2023-01-22 19:44:49 -08:00
Fabian Giesen
0613e9c043 stb_image: Tweak end-of-JPEG junk scanning loop.
Be a bit more picky about what we consider a valid marker.
0xff 0x00 (stuffed 0 byte) should not count.

Fixes issue #1409.
2023-01-22 19:42:55 -08:00
Fabian Giesen
1096389590 stb_image: Accept some extra data between BMP header and payload
Limit to 1k, which is the maximum size of a 256-entry palette that
would ordinarily go there. It feels sensible to relax this a bit but
we don't want to go overboard.

Fixes issue #1325.
2023-01-22 18:52:04 -08:00
Fabian Giesen
51d295e33e stb_image: Add trailing semicolon to usage example
Fixes issue #1330 reported by lunasorcery.
2023-01-22 16:16:02 -08:00
Fabian Giesen
038b6ab9ec stb_image: Avoid stdint.h on 32-bit Symbian.
As suggested by "mupfdev" on Github. We don't have a way to test
here but seems simple enough.

Fixes issue #1321.
2023-01-22 15:51:38 -08:00
Fabian Giesen
b15b04321d Merge branch 'NeilBickford-NV-neilbickford/additional-image-fixes' into dev 2023-01-22 15:33:45 -08:00
Fabian Giesen
4d160de463 stb_image: Fix name of stbi_set_unpremultiply_on_load_thread impl
Bug reported by N-R-K. Fixes #1276.
2023-01-22 15:29:01 -08:00
Fabian Giesen
e5da6acacd Merge branch 'neilbickford/image_hdr_pgm_fixes' into dev 2023-01-22 15:12:38 -08:00
Neil Bickford
9f22cc9008 stb_image PNG: Checks for invalid DEFLATE codes.
Specifically, this rejects length codes 286 and 287, and distance codes 30 and 31.
This avoids a scenario in which a file could contain a table in which
0 corresponded to length code 287, which would result in writing 0 bits.

Signed-off-by: Neil Bickford <nbickford@nvidia.com>
2023-01-22 15:07:14 -08:00
Neil Bickford
5cfc2a744a Zero-initialize stbi__jpeg to avoid intermittent errors found by fuzz-testing 2022-11-29 00:36:36 -08:00
Neil Bickford
47164e4086 Add checks for signed integer overflow; further guard against cases where stbi__grow_buffer_unsafe doesn't read all bits required. 2022-11-29 00:36:36 -08:00
Neil Bickford
96fe76c213 Add range checks to fix a few crash issues in stb_image issues 1289 and 1291 2022-11-29 00:36:36 -08:00
Neil Bickford
84b94010a7 Add checks for PNM integer read overflows, add a 1GB limit on IDAT chunk sizes to fix an OOM issue, and check for a situation where a sequence of bad Huffman code reads could result in a left shift by a negative number. 2022-11-29 00:36:36 -08:00
Neil Bickford
2a02ff76b5 Fixes two stb_image issues that could occur with specially constructed HDR and PGM files.
Signed-off-by: Neil Bickford <nbickford@nvidia.com>
2022-11-29 00:36:23 -08:00
Sean Barrett
8b5f1f37b5 update readme 2022-09-08 09:40:02 -07:00
Sean Barrett
bc00c178ac Merge branch 'master' of https://github.com/nothings/stb 2022-09-08 09:36:55 -07:00
Sean Barrett
4af130e863 stb_perlin.h: restore file now that patent is expired 2022-09-08 09:35:48 -07:00
Sean Barrett
af1a5bc352
Update bug_report.md 2021-09-10 00:48:29 -07:00
Sean Barrett
37e21f17b2
Update bug_report.md 2021-09-10 00:47:35 -07:00
Sean Barrett
b9e1d86edc
Create config.yml 2021-09-10 00:43:51 -07:00
Sean Barrett
b1826c9894 Update issue templates 2021-09-10 00:41:32 -07:00
Sean Barrett
c0c982601f stb_truetype 1.26: fix rendering glitches 2021-08-28 04:52:41 -07:00
Sean Barrett
ef861421e2 stb.h: stb_splitpath correctly handles relative paths with explicit drive specifiers 2021-08-28 03:20:04 -07:00
Sean Barrett
59e7dec3e8 delete file covered by patents 2021-08-13 13:57:23 -07:00
Sean Barrett
08e89524f6 Merge branch 'dev' of https://github.com/nothings/stb into dev 2021-08-13 13:57:07 -07:00
Fabian Giesen
5ba0baaa26 stb_image: Reject fractional JPEG component subsampling ratios
The component resamplers are not written to support this and I've
never seen it happen in a real (non-crafted) JPEG file so I'm
fine rejecting this as outright corrupt.

Fixes issue #1178.
2021-07-25 20:24:10 -07:00
Sean Barrett
c404b789ca stb_truetype: fix sample code drawing characters upside-down 2021-07-25 19:22:47 -07:00
Sean Barrett
1401f2257d clean up project file 2021-07-25 19:22:47 -07:00
Sean Barrett
7c65d5621f fix compiling with NO_HDR NO_LINEAR 2021-07-25 19:22:47 -07:00
Sean Barrett
be901954b2 stb_truetype: fix sample code drawing characters upside-down 2021-07-12 23:47:20 -07:00
Sean Barrett
7de8f7999b Merge branch 'master' into dev 2021-07-12 23:47:13 -07:00
Sean Barrett
3a1174060a opengl stb_truetype demo app 2021-07-12 21:27:12 -07:00
Sean Barrett
4adb57af42 clean up project file 2021-07-12 15:58:08 -07:00
Sean Barrett
cd6b6f70ec fix compiling with NO_HDR NO_LINEAR 2021-07-12 15:57:39 -07:00
Sean Barrett
a0a939058c update README 2021-07-12 01:50:47 -07:00
Sean Barrett
5a0bb8b1c1 update readme 2021-07-12 01:39:27 -07:00