Commit 4d483ab7 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'fscrypt-for-linus' of git://git.kernel.org/pub/scm/fs/fscrypt/linux

Pull fscrypt update from Eric Biggers:
 "Just one flex array conversion patch"

* tag 'fscrypt-for-linus' of git://git.kernel.org/pub/scm/fs/fscrypt/linux:
  fscrypt: Replace 1-element array with flexible array
parents f7976a64 d617ef03
...@@ -171,7 +171,7 @@ fscrypt_policy_flags(const union fscrypt_policy *policy) ...@@ -171,7 +171,7 @@ fscrypt_policy_flags(const union fscrypt_policy *policy)
*/ */
struct fscrypt_symlink_data { struct fscrypt_symlink_data {
__le16 len; __le16 len;
char encrypted_path[1]; char encrypted_path[];
} __packed; } __packed;
/** /**
......
...@@ -255,10 +255,10 @@ int fscrypt_prepare_symlink(struct inode *dir, const char *target, ...@@ -255,10 +255,10 @@ int fscrypt_prepare_symlink(struct inode *dir, const char *target,
* for now since filesystems will assume it is there and subtract it. * for now since filesystems will assume it is there and subtract it.
*/ */
if (!__fscrypt_fname_encrypted_size(policy, len, if (!__fscrypt_fname_encrypted_size(policy, len,
max_len - sizeof(struct fscrypt_symlink_data), max_len - sizeof(struct fscrypt_symlink_data) - 1,
&disk_link->len)) &disk_link->len))
return -ENAMETOOLONG; return -ENAMETOOLONG;
disk_link->len += sizeof(struct fscrypt_symlink_data); disk_link->len += sizeof(struct fscrypt_symlink_data) + 1;
disk_link->name = NULL; disk_link->name = NULL;
return 0; return 0;
...@@ -289,7 +289,7 @@ int __fscrypt_encrypt_symlink(struct inode *inode, const char *target, ...@@ -289,7 +289,7 @@ int __fscrypt_encrypt_symlink(struct inode *inode, const char *target,
if (!sd) if (!sd)
return -ENOMEM; return -ENOMEM;
} }
ciphertext_len = disk_link->len - sizeof(*sd); ciphertext_len = disk_link->len - sizeof(*sd) - 1;
sd->len = cpu_to_le16(ciphertext_len); sd->len = cpu_to_le16(ciphertext_len);
err = fscrypt_fname_encrypt(inode, &iname, sd->encrypted_path, err = fscrypt_fname_encrypt(inode, &iname, sd->encrypted_path,
...@@ -367,7 +367,7 @@ const char *fscrypt_get_symlink(struct inode *inode, const void *caddr, ...@@ -367,7 +367,7 @@ const char *fscrypt_get_symlink(struct inode *inode, const void *caddr,
* the ciphertext length, even though this is redundant with i_size. * the ciphertext length, even though this is redundant with i_size.
*/ */
if (max_size < sizeof(*sd)) if (max_size < sizeof(*sd) + 1)
return ERR_PTR(-EUCLEAN); return ERR_PTR(-EUCLEAN);
sd = caddr; sd = caddr;
cstr.name = (unsigned char *)sd->encrypted_path; cstr.name = (unsigned char *)sd->encrypted_path;
...@@ -376,7 +376,7 @@ const char *fscrypt_get_symlink(struct inode *inode, const void *caddr, ...@@ -376,7 +376,7 @@ const char *fscrypt_get_symlink(struct inode *inode, const void *caddr,
if (cstr.len == 0) if (cstr.len == 0)
return ERR_PTR(-EUCLEAN); return ERR_PTR(-EUCLEAN);
if (cstr.len + sizeof(*sd) - 1 > max_size) if (cstr.len + sizeof(*sd) > max_size)
return ERR_PTR(-EUCLEAN); return ERR_PTR(-EUCLEAN);
err = fscrypt_fname_alloc_buffer(cstr.len, &pstr); err = fscrypt_fname_alloc_buffer(cstr.len, &pstr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment