@@ -255,10 +255,10 @@ int fscrypt_prepare_symlink(struct inode *dir, const char *target,
255
255
* for now since filesystems will assume it is there and subtract it.
256
256
*/
257
257
if (!__fscrypt_fname_encrypted_size (policy , len ,
258
- max_len - sizeof (struct fscrypt_symlink_data ),
258
+ max_len - sizeof (struct fscrypt_symlink_data ) - 1 ,
259
259
& disk_link -> len ))
260
260
return - ENAMETOOLONG ;
261
- disk_link -> len += sizeof (struct fscrypt_symlink_data );
261
+ disk_link -> len += sizeof (struct fscrypt_symlink_data ) + 1 ;
262
262
263
263
disk_link -> name = NULL ;
264
264
return 0 ;
@@ -289,7 +289,7 @@ int __fscrypt_encrypt_symlink(struct inode *inode, const char *target,
289
289
if (!sd )
290
290
return - ENOMEM ;
291
291
}
292
- ciphertext_len = disk_link -> len - sizeof (* sd );
292
+ ciphertext_len = disk_link -> len - sizeof (* sd ) - 1 ;
293
293
sd -> len = cpu_to_le16 (ciphertext_len );
294
294
295
295
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
367
* the ciphertext length, even though this is redundant with i_size.
368
368
*/
369
369
370
- if (max_size < sizeof (* sd ))
370
+ if (max_size < sizeof (* sd ) + 1 )
371
371
return ERR_PTR (- EUCLEAN );
372
372
sd = caddr ;
373
373
cstr .name = (unsigned char * )sd -> encrypted_path ;
@@ -376,7 +376,7 @@ const char *fscrypt_get_symlink(struct inode *inode, const void *caddr,
376
376
if (cstr .len == 0 )
377
377
return ERR_PTR (- EUCLEAN );
378
378
379
- if (cstr .len + sizeof (* sd ) - 1 > max_size )
379
+ if (cstr .len + sizeof (* sd ) > max_size )
380
380
return ERR_PTR (- EUCLEAN );
381
381
382
382
err = fscrypt_fname_alloc_buffer (cstr .len , & pstr );
0 commit comments