mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
Fix warnings reported by static analysis.
- ensure that strings are \0 terminated (most of this is already handled on higher level anyway) - fix resource leak in error path in tcrypt.c - fix time of check/time of use race in sysfs path processing - insruct Coverity scanner to ignore constant expression in random.c (it is intented to stop compile-time misconfiguration of RNG that would be fatal)
This commit is contained in:
@@ -279,24 +279,30 @@ char *crypt_get_partition_device(const char *dev_path, uint64_t offset, uint64_t
|
||||
major(st.st_rdev), minor(st.st_rdev)) < 0)
|
||||
return NULL;
|
||||
|
||||
len = readlink(path, link, sizeof(link) - 1);
|
||||
if (len < 0)
|
||||
dir = opendir(path);
|
||||
if (!dir)
|
||||
return NULL;
|
||||
|
||||
len = readlink(path, link, sizeof(link) - 1);
|
||||
if (len < 0) {
|
||||
closedir(dir);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Get top level disk name for sysfs search */
|
||||
link[len] = '\0';
|
||||
devname = strrchr(link, '/');
|
||||
if (!devname)
|
||||
if (!devname) {
|
||||
closedir(dir);
|
||||
return NULL;
|
||||
}
|
||||
devname++;
|
||||
|
||||
/* DM devices do not use kernel partitions. */
|
||||
if (dm_is_dm_kernel_name(devname))
|
||||
return NULL;
|
||||
|
||||
dir = opendir(path);
|
||||
if (!dir)
|
||||
if (dm_is_dm_kernel_name(devname)) {
|
||||
closedir(dir);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
devname_len = strlen(devname);
|
||||
while((entry = readdir(dir))) {
|
||||
|
||||
Reference in New Issue
Block a user