]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
sunrpc: Fix UB on xdr_hyper
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 22 Apr 2025 17:55:38 +0000 (14:55 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 7 May 2025 17:21:21 +0000 (14:21 -0300)
ubsan triggers:

UBSAN: Undefined behaviour in xdr.c:262:28 left shift of 18446744073709551615 by 32 cannot be represented in type 'long int'

Fix by using unsigned type cast for left shift.

sunrpc/xdr.c

index a76094d6dab550e116eed407f679c17bf9992e74..b7b139520e682f9c9445fbe132210d9be8fd86e8 100644 (file)
@@ -259,7 +259,7 @@ xdr_hyper (XDR *xdrs, quad_t *llp)
     {
       if (!XDR_GETLONG(xdrs, &t1) || !XDR_GETLONG(xdrs, &t2))
        return FALSE;
-      *llp = ((quad_t) t1) << 32;
+      *llp = ((u_quad_t) t1) << 32;
       *llp |= (uint32_t) t2;
       return TRUE;
     }