sip: both framers read a Content-Length as a number

DatagramMessage read the first nine characters of a Content-Length, the
zeros before its number among them: a length written 0000000005 came out
as 0, and the body after it was cut off as bytes past the message.
FrameBuffer read the value into a long, and one too long for that
counted as no Content-Length: the body was framed as the start of the
next message. RFC 3261 25.1 writes the value as 1*DIGIT.

LengthOf reads it for both: the number its leading digits spell, zeros
before it aside; of a number of more than nine digits the first nine,
more than a datagram holds and enough that a stream waits. A value that
begins with no digit is no length, as before.

Tested by tests/Sip through both framers: a length of one digit written
with ten zeros before it frames that many bytes; a twenty-digit length
that wraps to zero in 64 bits is a datagram cut short and a stream's
body waited for; a value without a leading digit leaves a datagram's
body the rest of it and a stream's empty.
This commit is contained in:
Jorijn van der Graaf 2026-11-22 17:35:11 +01:00
commit c81dd3d267
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
3 changed files with 40 additions and 10 deletions

View file

@ -291,7 +291,9 @@ What the suites pin:
- `Sip` — the text layer's edge cases (empty header values, line anchoring,
keepalive discards, a header read that stops at the first empty line — a
body line spelling a header name picks nothing, leading empty lines are
skipped), the twelve compact forms (each through `Header`, in lower and
skipped), the Content-Length the two framers read (zeros before its
number no part of it; a number past any that fits not read as zero; a
value that begins with no digit read as none), the twelve compact forms (each through `Header`, in lower and
in upper case, and through `Headers`; no other letter taken for a
header name the suite lists; `l:` through the framer and
`DatagramMessage`), `ViaResponsePort`'s reading of a Via row — `rport` by its name (in