mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-13 14:24:11 +08:00
xdrgen: Fix return code checking in built-in XDR decoders
xdr_stream_encode_u32() returns XDR_UNIT on success. xdr_stream_decode_u32() returns zero or -EMSGSIZE, but never XDR_UNIT. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
parent
4b132aacb0
commit
663ad8b1df
@ -184,7 +184,7 @@ xdrgen_decode_string(struct xdr_stream *xdr, string *ptr, u32 maxlen)
|
||||
__be32 *p;
|
||||
u32 len;
|
||||
|
||||
if (unlikely(xdr_stream_decode_u32(xdr, &len) != XDR_UNIT))
|
||||
if (unlikely(xdr_stream_decode_u32(xdr, &len) < 0))
|
||||
return false;
|
||||
if (unlikely(maxlen && len > maxlen))
|
||||
return false;
|
||||
@ -215,7 +215,7 @@ xdrgen_decode_opaque(struct xdr_stream *xdr, opaque *ptr, u32 maxlen)
|
||||
__be32 *p;
|
||||
u32 len;
|
||||
|
||||
if (unlikely(xdr_stream_decode_u32(xdr, &len) != XDR_UNIT))
|
||||
if (unlikely(xdr_stream_decode_u32(xdr, &len) < 0))
|
||||
return false;
|
||||
if (unlikely(maxlen && len > maxlen))
|
||||
return false;
|
||||
|
@ -2,7 +2,7 @@
|
||||
{% if annotate %}
|
||||
/* member {{ name }} (variable-length array) */
|
||||
{% endif %}
|
||||
if (xdr_stream_decode_u32(xdr, &ptr->{{ name }}.count) != XDR_UNIT)
|
||||
if (xdr_stream_decode_u32(xdr, &ptr->{{ name }}.count) < 0)
|
||||
return false;
|
||||
{% if maxsize != "0" %}
|
||||
if (ptr->{{ name }}.count > {{ maxsize }})
|
||||
|
@ -2,7 +2,7 @@
|
||||
{% if annotate %}
|
||||
/* member {{ name }} (variable-length array) */
|
||||
{% endif %}
|
||||
if (xdr_stream_decode_u32(xdr, &ptr->{{ name }}.count) != XDR_UNIT)
|
||||
if (xdr_stream_decode_u32(xdr, &ptr->{{ name }}.count) < 0)
|
||||
return false;
|
||||
{% if maxsize != "0" %}
|
||||
if (ptr->{{ name }}.count > {{ maxsize }})
|
||||
|
@ -2,7 +2,7 @@
|
||||
{% if annotate %}
|
||||
/* member {{ name }} (variable-length array) */
|
||||
{% endif %}
|
||||
if (xdr_stream_decode_u32(xdr, &count) != XDR_UNIT)
|
||||
if (xdr_stream_decode_u32(xdr, &count) < 0)
|
||||
return false;
|
||||
if (count > {{ maxsize }})
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user