]> git.apps.os.sepia.ceph.com Git - ceph-client.git/commitdiff
ceph: fix base64 encoded name's length check in ceph_fname_to_usr()
authorXiubo Li <xiubli@redhat.com>
Fri, 11 Mar 2022 04:15:05 +0000 (12:15 +0800)
committerXiubo Li <xiubli@redhat.com>
Thu, 18 Aug 2022 02:59:51 +0000 (10:59 +0800)
The fname->name is based64_encoded names and the max long shouldn't
exceed the NAME_MAX.

The FSCRYPT_BASE64URL_CHARS(NAME_MAX) will be 255 * 4 / 3.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
fs/ceph/crypto.c

index 5691222bea09cce148a9a62ace5073a44ab5a927..2222f4968f74b41b652747f706d956bf328c8038 100644 (file)
@@ -264,7 +264,7 @@ int ceph_fname_to_usr(const struct ceph_fname *fname, struct fscrypt_str *tname,
        }
 
        /* Sanity check that the resulting name will fit in the buffer */
-       if (fname->name_len > FSCRYPT_BASE64URL_CHARS(NAME_MAX))
+       if (fname->name_len > NAME_MAX || fname->ctext_len > NAME_MAX)
                return -EIO;
 
        ret = __fscrypt_prepare_readdir(fname->dir);