Merge branch 'bugfixes' into nfs-for-next
[firefly-linux-kernel-4.4.55.git] / fs / nfs / nfs4xdr.c
index e786dc7582b1b2e6f886c489c8294634ffb96f11..26b143920433e628456476e0d1b708b8fc395d43 100644 (file)
@@ -271,6 +271,8 @@ static int nfs4_stat_to_errno(int);
 
 #if defined(CONFIG_NFS_V4_1)
 #define NFS4_MAX_MACHINE_NAME_LEN (64)
+#define IMPL_NAME_LIMIT (sizeof(utsname()->sysname) + sizeof(utsname()->release) + \
+                        sizeof(utsname()->version) + sizeof(utsname()->machine) + 8)
 
 #define encode_exchange_id_maxsz (op_encode_hdr_maxsz + \
                                encode_verifier_maxsz + \
@@ -283,7 +285,7 @@ static int nfs4_stat_to_errno(int);
                                1 /* nii_domain */ + \
                                XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \
                                1 /* nii_name */ + \
-                               XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \
+                               XDR_QUADLEN(IMPL_NAME_LIMIT) + \
                                3 /* nii_date */)
 #define decode_exchange_id_maxsz (op_decode_hdr_maxsz + \
                                2 /* eir_clientid */ + \
@@ -1712,7 +1714,7 @@ static void encode_exchange_id(struct xdr_stream *xdr,
                               struct compound_hdr *hdr)
 {
        __be32 *p;
-       char impl_name[NFS4_OPAQUE_LIMIT];
+       char impl_name[IMPL_NAME_LIMIT];
        int len = 0;
 
        encode_op_hdr(xdr, OP_EXCHANGE_ID, decode_exchange_id_maxsz, hdr);
@@ -1727,7 +1729,7 @@ static void encode_exchange_id(struct xdr_stream *xdr,
        if (send_implementation_id &&
            sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 &&
            sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN)
-               <= NFS4_OPAQUE_LIMIT + 1)
+               <= sizeof(impl_name) + 1)
                len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s",
                               utsname()->sysname, utsname()->release,
                               utsname()->version, utsname()->machine);