]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Fix an undefined behavior at runtime in parsenfsfh.c
authorFrancois-Xavier Le Bail <[email protected]>
Tue, 10 Jul 2018 19:43:31 +0000 (21:43 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Tue, 10 Jul 2018 19:56:25 +0000 (21:56 +0200)
The error was:
parsenfsfh.c:359:37: runtime error: left shift of 170 by 24 places cannot
be represented in type 'int'

parsenfsfh.c

index 06896cd1a64d595c1d2bfc90dd5ff43c3d5cfee7..79648abe888ce75a3218c88ba186c11d354a0ce9 100644 (file)
@@ -356,8 +356,8 @@ Parse_fh(const unsigned char *fh, u_int len, my_fsid *fsidp,
            }
 
            /* VMS file ID is: (RVN, FidHi, FidLo) */
-           *inop = (EXTRACT_U_1(fhp + 26) << 24) |
-                   (EXTRACT_U_1(fhp + 27) << 16) |
+           *inop = (((uint32_t)EXTRACT_U_1(fhp + 26)) << 24) |
+                   (((uint32_t)EXTRACT_U_1(fhp + 27)) << 16) |
                    (EXTRACT_LE_U_2(fhp + 22) << 0);
 
            /* Caller must save (and null-terminate?) this value */