Skip to content

Commit e87cf8a

Browse files
Dan Carpenteramschuma-ntap
authored andcommitted
SUNRPC: clean up integer overflow check
This integer overflow check works as intended but Clang and GCC and warn about it when compiling with W=1. include/linux/sunrpc/xdr.h:539:17: error: comparison is always false due to limited range of data type [-Werror=type-limits] Use size_mul() to prevent the integer overflow. It silences the warning and it's cleaner as well. Reported-by: Dmitry Antipov <dmantipov@yandex.ru> Closes: https://lore.kernel.org/all/20230601143332.255312-1-dmantipov@yandex.ru/ Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Acked-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent f9597ba commit e87cf8a

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

  • include/linux/sunrpc

include/linux/sunrpc/xdr.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -777,9 +777,7 @@ xdr_stream_decode_uint32_array(struct xdr_stream *xdr,
777777

778778
if (unlikely(xdr_stream_decode_u32(xdr, &len) < 0))
779779
return -EBADMSG;
780-
if (len > SIZE_MAX / sizeof(*p))
781-
return -EBADMSG;
782-
p = xdr_inline_decode(xdr, len * sizeof(*p));
780+
p = xdr_inline_decode(xdr, size_mul(len, sizeof(*p)));
783781
if (unlikely(!p))
784782
return -EBADMSG;
785783
if (array == NULL)

0 commit comments

Comments
 (0)