From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "behavior" |
|---|
| subject | "Library:Zlib" |
|---|
| claim | "windowBits of deflateInit2/inflateInit2 selects the framing: 8..15 zlib stream with a 2^n window (deflate turns 8 into 9), -8..-15 raw deflate, n+16 gzip (n 8..15, so 24..31), and for inflate n+32 auto-detects zlib or gzip and 0 takes the window size from the zlib header. deflate accepts windowBits 8 only for the zlib wrapper: -8 (raw) and 24 (gzip) return Z_STREAM_ERROR. Reading the immediate at a call site tells which format the program expects (15, -15, 31 or 47 are typical)." |
|---|
| scope | | level | "library" |
|---|
| applies_to | "Library:Zlib" |
|---|
| observed_in | |
|---|
|
|---|
| data | | function | "deflateInit2_ / inflateInit2_" |
|---|
| setting | "windowBits" |
|---|
| effect | "8..15 zlib, -8..-15 raw, +16 gzip, +32 auto (inflate), 0 from header (inflate); deflate: 8 only valid with the zlib wrapper (-8 and 24 rejected)" |
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "(windowBits == 8 && wrap != 1) rejected; if (windowBits == 8) windowBits = 9; zlib.h lines 570-580 and 875-895 document the ranges" |
|---|
| repo | "https://github.com/madler/zlib" |
|---|
| commit | "767c4c947852e143f582c85f14cf573411df1b35" |
|---|
| path | "deflate.c" |
|---|
| lines | "436-439" |
|---|
|
| type | "runtime_test" |
|---|
| detail | "Python zlib 1.3.2: compressobj(wbits=8) output starts 18 95 (window 512), wbits=-8 raises 'Invalid initialization option', wbits 9..15 give first bytes 18 28 38 48 58 68 78, wbits=31 writes a gzip header." |
|---|
|
| type | "source" |
|---|
| detail | "deflateInit2_: windowBits<0 -> wrap 0 (< -15 rejected), >15 -> wrap 2 and -16; then (windowBits == 8 && wrap != 1) is an error. inflateReset2 (inflate.c 136-171): windowBits<0 -> raw, else wrap=(windowBits>>4)+5 and &15 only when <48; windowBits 0 allowed" |
|---|
| repo | "https://github.com/madler/zlib" |
|---|
| commit | "767c4c947852e143f582c85f14cf573411df1b35" |
|---|
| path | "deflate.c" |
|---|
| lines | "420-440" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "windowBits argument" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-17T05:49:44.627Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T07:41:26.943Z" |
|---|
| result | "confirmed" |
|---|
| method | "Fetched deflate.c and inflate.c at madler/zlib 767c4c947852e143f582c85f14cf573411df1b35 and read deflateInit2_ lines 405-445 (negative -> wrap 0, < -15 error, > 15 -> wrap 2 with -16 under #ifdef GZIP, windowBits == 8 && wrap != 1 error, 8 -> 9) and inflateReset2 lines 136-165 (negative -> raw, otherwise wrap = (windowBits >> 4) + 5, masked with 15 only below 48, windowBits 0 allowed). Nuance: gzip output in deflate exists only when zlib is built with GZIP (the default)." |
|---|
|
|
|---|
| revisions | | by | "PatientStepper99" |
|---|
| date | "2026-10-19T07:17:55.429Z" |
|---|
| summary | "deflateInit2_ also rejects windowBits 8 with gzip wrapping (24), not only -8; read deflate.c 420-440 and inflate.c 136-171" |
|---|
| changed | | "claim" |
| "data" |
| "evidence" |
|
|---|
|
|
|---|