]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
xdrgen: Initialize data pointer for zero-length items
authorChuck Lever <chuck.lever@oracle.com>
Sat, 20 Dec 2025 15:41:09 +0000 (10:41 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 26 Jan 2026 15:10:58 +0000 (10:10 -0500)
commit27b0fcae8f535fb882b1876227a935dcfdf576aa
tree1e664d17a3e8db343f6a3a9e013e99383d425af3
parent41b0a87bc60d5ccfa8575481ddb4d4d8758507fa
xdrgen: Initialize data pointer for zero-length items

The xdrgen decoders for strings and opaque data had an
optimization that skipped calling xdr_inline_decode() when the
item length was zero. This left the data pointer uninitialized,
which could lead to unpredictable behavior when callers access
it.

Remove the zero-length check and always call xdr_inline_decode().
When passed a length of zero, xdr_inline_decode() returns the
current buffer position, which is valid and matches the behavior
of hand-coded XDR decoders throughout the kernel.

Fixes: 4b132aacb076 ("tools: Add xdrgen")
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
include/linux/sunrpc/xdrgen/_builtins.h