fix warning

Signed-off-by: 张文迪 <zhangwendi3@huawei.com>
This commit is contained in:
张文迪 2023-08-14 19:38:59 +08:00
parent e875536a39
commit 38aabec1ac
2 changed files with 20 additions and 3 deletions

View File

@ -277,8 +277,13 @@ static int ReadKeyFile(const char *path, char *buf, size_t len)
FSCRYPT_LOGE("target file size is not equal to buf len");
return -EFAULT;
}
char *realPath = realpath(path, NULL);
if (realPath == NULL) {
FSCRYPT_LOGE("realpath failed");
return -EFAULT;
}
int fd = open(path, O_RDONLY);
int fd = open(realPath, O_RDONLY);
if (fd < 0) {
FSCRYPT_LOGE("key file read open failed");
return -EFAULT;

View File

@ -64,7 +64,13 @@ long KeyCtrlUnlink(key_serial_t key, key_serial_t keyring)
static bool FsIoctl(const char *mnt, unsigned long cmd, void *arg)
{
int fd = open(mnt, O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
char *realPath = realpath(mnt, NULL);
if (realPath == NULL) {
FSCRYPT_LOGE("realpath failed");
return false;
}
int fd = open(realPath, O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
if (fd < 0) {
FSCRYPT_LOGE("open %s failed, errno:%d", mnt, errno);
return false;
@ -119,7 +125,13 @@ bool KeyCtrlGetPolicy(const char *path, struct fscrypt_policy *policy)
static uint8_t CheckKernelFscrypt(const char *mnt)
{
int fd = open(mnt, O_RDONLY | O_DIRECTORY | O_CLOEXEC);
char *realPath = realpath(mnt, NULL);
if (realPath == NULL) {
FSCRYPT_LOGE("realpath failed");
return -EFAULT;
}
int fd = open(realPath, O_RDONLY | O_DIRECTORY | O_CLOEXEC);
if (fd < 0) {
FSCRYPT_LOGE("open policy file failed, errno: %d", errno);
return FSCRYPT_INVALID;