diff options
author | Eric Biggers <ebiggers@google.com> | 2016-09-15 17:25:55 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2016-09-15 17:25:55 -0400 |
commit | ef1eb3aa50930f026135085cd160b1212cdfe817 (patch) | |
tree | 12ed99fd9e7dc658b0e1bb0bc78e2ad0bb887dca /fs/ext4/symlink.c | |
parent | 53fd7550ec40571e26f730a0d3fc0a5dd93ecda2 (diff) |
fscrypto: make filename crypto functions return 0 on success
Several filename crypto functions: fname_decrypt(),
fscrypt_fname_disk_to_usr(), and fscrypt_fname_usr_to_disk(), returned
the output length on success or -errno on failure. However, the output
length was redundant with the value written to 'oname->len'. It is also
potentially error-prone to make callers have to check for '< 0' instead
of '!= 0'.
Therefore, make these functions return 0 instead of a length, and make
the callers who cared about the return value being a length use
'oname->len' instead. For consistency also make other callers check for
a nonzero result rather than a negative result.
This change also fixes the inconsistency of fname_encrypt() actually
already returning 0 on success, not a length like the other filename
crypto functions and as documented in its function comment.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Acked-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/ext4/symlink.c')
-rw-r--r-- | fs/ext4/symlink.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/ext4/symlink.c b/fs/ext4/symlink.c index 04a7850a0d45..0a26cbd529c8 100644 --- a/fs/ext4/symlink.c +++ b/fs/ext4/symlink.c @@ -68,12 +68,11 @@ static const char *ext4_encrypted_get_link(struct dentry *dentry, paddr = pstr.name; res = fscrypt_fname_disk_to_usr(inode, 0, 0, &cstr, &pstr); - if (res < 0) + if (res) goto errout; /* Null-terminate the name */ - if (res <= pstr.len) - paddr[res] = '\0'; + paddr[pstr.len] = '\0'; if (cpage) put_page(cpage); set_delayed_call(done, kfree_link, paddr); |