Skip to content

Commit 4d483ab

Browse files
committed
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
2 parents f7976a6 + d617ef0 commit 4d483ab

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

fs/crypto/fscrypt_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ fscrypt_policy_flags(const union fscrypt_policy *policy)
171171
*/
172172
struct fscrypt_symlink_data {
173173
__le16 len;
174-
char encrypted_path[1];
174+
char encrypted_path[];
175175
} __packed;
176176

177177
/**

fs/crypto/hooks.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,10 @@ int fscrypt_prepare_symlink(struct inode *dir, const char *target,
255255
* for now since filesystems will assume it is there and subtract it.
256256
*/
257257
if (!__fscrypt_fname_encrypted_size(policy, len,
258-
max_len - sizeof(struct fscrypt_symlink_data),
258+
max_len - sizeof(struct fscrypt_symlink_data) - 1,
259259
&disk_link->len))
260260
return -ENAMETOOLONG;
261-
disk_link->len += sizeof(struct fscrypt_symlink_data);
261+
disk_link->len += sizeof(struct fscrypt_symlink_data) + 1;
262262

263263
disk_link->name = NULL;
264264
return 0;
@@ -289,7 +289,7 @@ int __fscrypt_encrypt_symlink(struct inode *inode, const char *target,
289289
if (!sd)
290290
return -ENOMEM;
291291
}
292-
ciphertext_len = disk_link->len - sizeof(*sd);
292+
ciphertext_len = disk_link->len - sizeof(*sd) - 1;
293293
sd->len = cpu_to_le16(ciphertext_len);
294294

295295
err = fscrypt_fname_encrypt(inode, &iname, sd->encrypted_path,
@@ -367,7 +367,7 @@ const char *fscrypt_get_symlink(struct inode *inode, const void *caddr,
367367
* the ciphertext length, even though this is redundant with i_size.
368368
*/
369369

370-
if (max_size < sizeof(*sd))
370+
if (max_size < sizeof(*sd) + 1)
371371
return ERR_PTR(-EUCLEAN);
372372
sd = caddr;
373373
cstr.name = (unsigned char *)sd->encrypted_path;
@@ -376,7 +376,7 @@ const char *fscrypt_get_symlink(struct inode *inode, const void *caddr,
376376
if (cstr.len == 0)
377377
return ERR_PTR(-EUCLEAN);
378378

379-
if (cstr.len + sizeof(*sd) - 1 > max_size)
379+
if (cstr.len + sizeof(*sd) > max_size)
380380
return ERR_PTR(-EUCLEAN);
381381

382382
err = fscrypt_fname_alloc_buffer(cstr.len, &pstr);

0 commit comments

Comments
 (0)