Visual RFC.
ALL RFCs / RFC 4506
Read the RFC ↗
RFC 4506 / External data representation

Encode opaque bytes and counted ASCII strings

03

Fixed opaque data has no count prefix. Variable opaque data and strings have a four-byte byte count, then payload and residual zero padding.

RFC 4506 · § 4.9EXAMPLE
4 / 4
Encode opaque bytes and counted ASCII stringsCount9 violates chosen declaration bound8. Stop selected decoder before allocation or value acceptance; no data delivery follows.Separate payload counts from zero padding00000009Declared maximum: 8payload bytesIncoming count: 9payload bytesCount9 exceeds bound8Chosen decoder stops before allocationOpaque is bytes · base XDR strings are counted ASCII
04
Reject a length beyond the declaration

The selected decoder checks the bound before treating the announced length as a buffer request. No allocation or data acceptance follows this failed gate.

Source for this drawing: RFC 4506 · Read RFC section 4.9 ↗

Protocol participantThreat or exceptionProtocol controlSimplified drawings · precise section references
New to this? Start hereA quick picture + helpful background

First, agree how to read the message.

An encoding tells a reader how to interpret bytes. A format tells it how values fit together. Correctly reading a value does not make that value trustworthy.

Helpful first, if these ideas are unfamiliar

These pictures are analogies to help you learn. The linked RFC explains the actual rules.

Related RFCs and changes

“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.

KEY POINT

Count payload bytes, exclude padding, and respect the declared maximum.

  • Opaque means uninterpreted bytes. Fixed opaque data declared opaque sample[5] carries exactly five bytes plus three residual zero bytes; it has no count prefix. The type description supplies its size (§4.9).
  • Variable opaque data declared opaque sample<8> begins with an unsigned 32-bit byte count n. Five payload bytes therefore use count 00 00 00 05, five bytes and three zero bytes: twelve bytes total. The maximum8 is a declaration bound, not another transmitted number (§4.10).
  • An XDR string is a counted sequence of ASCII bytes. The string "cat" has count 3, bytes63 61 74, then one zero pad byte. XDR does not append a C-style terminator as part of the string. A zero pad byte is outside the count; an embedded NUL can instead be a counted string byte and creates native-API hazards (§§4.11,8). No automatic UTF-8 extension is assumed.
  • An omitted bound <> means a maximum of 2^32−1, not unlimited memory or a safe allocation size. Encoding a count beyond the declared maximum is an error. Decoders still need to ensure incoming sizes fit provisioned buffers even when the description has a large or omitted bound (§§4.10–4.11,8).
  • The fourth state illustrates count 9 against an explicit bound 8 and stops a chosen decoder before allocation. This is a local safety gate, not a new wire exchange. Empty counted data has count 0 and no payload/padding. Residual bytes in the representation are zero; the helper additionally chooses strict rejection of nonzero padding, not an invented universal decoder MUST.
DETAILS

Illustrative values and bounded offline encoding/decoding models. Not a complete XDR compiler, RPC/NFS implementation, transport, memory allocator or security verifier.

Read the RFC section ↗

All chapters in RFC 4506

Drawing view

Scroll the drawing to see every part. Playback controls stay above it.

RFC 9700 / CHAPTERS

Chapters

For full details, tables, algorithms, and exceptions, read the original RFC.

RFC status and corrections ↗