XdrBuffer
in package
Enables easy iteration through a blob of XDR data.
Provides an optional recursion-depth guard for XDR types that decode themselves recursively (e.g. XdrSorobanDelegateSignature). Call enterRecursion() at the start of each recursive call and leaveRecursion() on return. The guard throws InvalidArgumentException when the depth exceeds RECURSION_LIMIT (128), preventing stack exhaustion from hostile deep-nesting in data received from the network.
The guard counts true nesting depth, not array width or sequential fields, so wide transactions and large maps are unaffected.
Table of Contents
Constants
- RECURSION_LIMIT : mixed = 128
- Maximum allowed decode recursion depth (prevents stack exhaustion from hostile data).
Properties
Methods
- __construct() : mixed
- enterRecursion() : void
- Signals entry into one level of recursive XDR decoding.
- getRecursionDepth() : int
- Returns the current recursion depth.
- leaveRecursion() : void
- Signals exit from one level of recursive XDR decoding.
- readBigInteger64() : BigInteger
- readBoolean() : bool
- readInteger32() : int
- readInteger64() : int
- readOpaqueFixed() : string
- readOpaqueFixedString() : string
- readOpaqueVariable() : string
- readString() : string
- readUnsignedInteger256() : string
- readUnsignedInteger32() : int
- readUnsignedInteger64() : int
- assertBytesRemaining() : mixed
- roundTo4() : int
- rounds $number up to the nearest value that's a multiple of 4
Constants
RECURSION_LIMIT
Maximum allowed decode recursion depth (prevents stack exhaustion from hostile data).
public
mixed
RECURSION_LIMIT
= 128
Properties
$position
protected
int
$position
$size
protected
int
$size
$xdrBytes
protected
string
$xdrBytes
Methods
__construct()
public
__construct(string $xdrBytes) : mixed
Parameters
- $xdrBytes : string
enterRecursion()
Signals entry into one level of recursive XDR decoding.
public
enterRecursion() : void
Increments the depth counter and throws InvalidArgumentException when the limit is exceeded. Pair every call with a corresponding leaveRecursion() call.
Tags
getRecursionDepth()
Returns the current recursion depth.
public
getRecursionDepth() : int
Return values
int —current depth (0 at top level)
leaveRecursion()
Signals exit from one level of recursive XDR decoding.
public
leaveRecursion() : void
Decrements the depth counter. Must be called once for every successful enterRecursion() call, including on exception paths (use try/finally).
readBigInteger64()
public
readBigInteger64() : BigInteger
Return values
BigIntegerreadBoolean()
public
readBoolean() : bool
Return values
boolreadInteger32()
public
readInteger32() : int
Return values
intreadInteger64()
public
readInteger64() : int
Return values
intreadOpaqueFixed()
public
readOpaqueFixed(mixed $length) : string
Parameters
- $length : mixed
Return values
stringreadOpaqueFixedString()
public
readOpaqueFixedString(mixed $length) : string
Parameters
- $length : mixed
Return values
stringreadOpaqueVariable()
public
readOpaqueVariable([null $maxLength = null ]) : string
Parameters
- $maxLength : null = null
Return values
stringreadString()
public
readString([null $maxLength = null ]) : string
Parameters
- $maxLength : null = null
Return values
stringreadUnsignedInteger256()
public
readUnsignedInteger256() : string
Return values
stringreadUnsignedInteger32()
public
readUnsignedInteger32() : int
Return values
intreadUnsignedInteger64()
public
readUnsignedInteger64() : int
Return values
intassertBytesRemaining()
protected
assertBytesRemaining(mixed $numBytes) : mixed
Parameters
- $numBytes : mixed
roundTo4()
rounds $number up to the nearest value that's a multiple of 4
protected
roundTo4(mixed $number) : int
Parameters
- $number : mixed