You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: libnsgif: the last LZW code is lost when it ends on a byte boundary at the end of the data (upstream fix 2255b2f74) #2465
libnsgif's LZW code reader (libobs/graphics/libnsgif/lzw.c.h:175) asks for one byte too many on its slow path when a code ends exactly on a byte boundary (current_bit + code_size is a multiple of 8). If that code is the last one in the image data, there is no next sub-block, so the code is lost. The frame decode still reports success, and the last pixels stay empty.
Upstream fixed it on 2026-10-25 in netsurf-browser/libnsgif@2255b2f74 ("lzw: Fix off-by-one on code reader slow path", one line), with a regression test in 9abf1190d (test/data/lzweod.gif and .ppm). Our copy is libnsgif 1.0.0 (commit e0027ee4a, from upstream OBS) without it. The Rust image file (#1907) calls the same C, so the hybrid build has it too.
Not a vulnerability: every read stays inside the current sub-block (ctx->sb_bit < ctx->sb_bit_count is checked before each read). The effect is a wrong image.
Evidence
A small harness (unity build of our lzw.c.h + gif.c.h, NSGIF_BITMAP_FMT_R8G8B8A8) decodes upstream's lzweod.gif (3×1, one frame):
RED: a cmocka case (in test_image_file, or a small test_nsgif_lzw if that fits the one-binary-per-category rule better) that decodes lzweod.gif and compares frame 0 with the .ppm values. Fails on the current copy: the last pixel is 0 0 0.
GREEN: apply upstream's one-line change to lzw.c.h. Add the two test files with their origin (libnsgif, MIT, as LICENSE.libnsgif).
Size S. This also gives the Rust port of the LZW decoder (follow-up issue) the fixed C as its oracle.
Activity
vpacher commentedon Oct 26, 2026
Claiming: #2465
lzweod.gifand compares frame 0 withlzweod.ppm(fails now: the last pixel is 0 0 0).lzw.c.h, plus the two test files with their origin.PR today.
libnsgif: Fix the LZW code reader's off-by-one on the slow path (upst…
obs-graphics: Port the libnsgif LZW decoder (obs-rust#2466) (obs-rust…