Follow-up with measurements, because the effect is a bit more than "it 
crashes": the read
succeeds and feeds garbage into the paragraph bounds before the process dies.

Instrumented 1.2.9-9 (`-O0`, probe around the tail of `wvGetIntervalBounds`, no 
behaviour
change):

    OBS nopos=1 rgfc=0x556f5fc1d3c0 m2=00000021 m1=00000000

So the two words that the tail indexes (`rgfc[-2]`, `rgfc[-1]`) are `0x21` and 
`0x0` ―
neighbouring heap residue, not the paragraph's own bounds. For contrast, a 
healthy document
yields real values (`j=800 fcFirst=800 fcLim=85c`) at the same call site.

`wvNormFC()` is pure arithmetic (generic.c:117), so those residues are passed 
through
unchanged: `fcFirst` becomes `0x21` and `fcLim` becomes `0x0`, i.e. an inverted 
range. The
caller in `decode_simple.c:364` stores them into `para_fcFirst` / `para_fcLim`, 
compares
them against the current FC and hands them to `wvAssembleSimplePAP()`, so the 
following PAP
assembly and text walk run against a bogus interval instead of the real one.

The churn is measurable: with a guard that substitutes the sentinel `0` / 
`0xffffffff` at
that point, the refresh branch at `decode_simple.c:361` fires 9 times on the 
attached file
versus 1 time on a healthy document ― the bounds state keeps being invalidated 
and refetched.

Summary of the defect: an out-of-bounds read of two heap words that are then 
used as file
offsets, producing an inverted paragraph range and, on this input, a SIGSEGV at 
the read.

The guard patch from the report removes the read and the crash and keeps normal 
output
byte-identical.

Reply via email to