HexDecodeOddLengthLiteral
warning native on by default PHP ≥ 5.4Group: Probable bugs
Hexadecimal decoding requires complete pairs of digits. Supply an even number of hexadecimal characters.
Example
php
<?php
hex2bin("abc");Reported:
- line 2: Provide an even number of hexadecimal digits.
Detection
- Resolved hex2bin receives a constant string of odd byte length containing only ASCII hexadecimal digits. Highlight input argument.
- Resolve builtin functions, classes, constants and methods; user-defined lookalikes are excluded. Follow only bounded local proof in one lexical scope.
- Emit one finding per violating operation, not per supporting evidence statement. When the proof is inconclusive, nothing is reported.
Exceptions (no report)
- Do not report unresolved or shadowed builtin names, unknown values, or incomplete receiver/type provenance. Unknown calls, aliases escaping, and intervening writes invalidate local proof. Similar code outside the stated detection contract is not a finding.
- Both standard suppression forms suppress this native ID.
Fix
None. Choosing a repair requires intent or additional runtime information.
PHP versions
Requires PHP 5.4 or later.
Configure
In custos.json:
json
{
"rules": {
"HexDecodeOddLengthLiteral": {
"enabled": false
}
}
}Suppress
Before the statement or declaration (or the first statement of the file):
php
// @custos-ignore HexDecodeOddLengthLiteral