mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
Remove VLAs from UUID block parsing code.
This commit is contained in:
@@ -159,7 +159,7 @@ char *crypt_get_partition_device(const char *dev_path, uint64_t offset, uint64_t
|
||||
char *crypt_get_base_device(const char *dev_path);
|
||||
uint64_t crypt_dev_partition_offset(const char *dev_path);
|
||||
int lookup_by_disk_id(const char *dm_uuid);
|
||||
int lookup_by_sysfs_uuid_field(const char *dm_uuid, size_t max_len);
|
||||
int lookup_by_sysfs_uuid_field(const char *dm_uuid);
|
||||
int crypt_uuid_cmp(const char *dm_uuid, const char *hdr_uuid);
|
||||
|
||||
size_t crypt_getpagesize(void);
|
||||
|
||||
@@ -56,4 +56,10 @@
|
||||
#define DEFAULT_DISK_ALIGNMENT 1048576 /* 1MiB */
|
||||
#define DEFAULT_MEM_ALIGNMENT 4096
|
||||
|
||||
#define DM_UUID_LEN 129
|
||||
#define DM_BY_ID_PREFIX "dm-uuid-"
|
||||
#define DM_BY_ID_PREFIX_LEN 8
|
||||
#define DM_UUID_PREFIX "CRYPT-"
|
||||
#define DM_UUID_PREFIX_LEN 6
|
||||
|
||||
#endif /* _LIBCRYPTSETUP_MACROS_H */
|
||||
|
||||
@@ -36,11 +36,6 @@
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#define DM_UUID_LEN 129
|
||||
#define DM_BY_ID_PREFIX "dm-uuid-"
|
||||
#define DM_BY_ID_PREFIX_LEN 8
|
||||
#define DM_UUID_PREFIX "CRYPT-"
|
||||
#define DM_UUID_PREFIX_LEN 6
|
||||
#define DM_CRYPT_TARGET "crypt"
|
||||
#define DM_VERITY_TARGET "verity"
|
||||
#define DM_INTEGRITY_TARGET "integrity"
|
||||
@@ -1244,7 +1239,7 @@ int lookup_dm_dev_by_uuid(struct crypt_device *cd, const char *uuid, const char
|
||||
r = lookup_by_disk_id(dev_uuid);
|
||||
if (r == -ENOENT) {
|
||||
log_dbg(cd, "Search by disk id not available. Using sysfs instead.");
|
||||
r = lookup_by_sysfs_uuid_field(dev_uuid + DM_BY_ID_PREFIX_LEN, DM_UUID_LEN);
|
||||
r = lookup_by_sysfs_uuid_field(dev_uuid + DM_BY_ID_PREFIX_LEN);
|
||||
}
|
||||
|
||||
return r;
|
||||
|
||||
@@ -406,10 +406,10 @@ int lookup_by_disk_id(const char *dm_uuid)
|
||||
return r;
|
||||
}
|
||||
|
||||
int lookup_by_sysfs_uuid_field(const char *dm_uuid, size_t max_len)
|
||||
int lookup_by_sysfs_uuid_field(const char *dm_uuid)
|
||||
{
|
||||
struct dirent *entry;
|
||||
char subpath[PATH_MAX], uuid[max_len];
|
||||
char subpath[PATH_MAX], uuid[DM_UUID_LEN];
|
||||
ssize_t s;
|
||||
struct stat st;
|
||||
int fd, len, r = 0; /* not found */
|
||||
@@ -441,7 +441,7 @@ int lookup_by_sysfs_uuid_field(const char *dm_uuid, size_t max_len)
|
||||
}
|
||||
|
||||
/* reads binary data */
|
||||
s = read_buffer(fd, uuid, max_len - 1);
|
||||
s = read_buffer(fd, uuid, sizeof(uuid) - 1);
|
||||
if (s > 0) {
|
||||
uuid[s] = '\0';
|
||||
if (!strncmp(uuid, dm_uuid, strlen(dm_uuid)))
|
||||
|
||||
@@ -26,11 +26,6 @@
|
||||
#endif
|
||||
#include <uuid/uuid.h>
|
||||
|
||||
#define DM_UUID_LEN 129
|
||||
#define DM_BY_ID_PREFIX "dm-uuid-"
|
||||
#define DM_BY_ID_PREFIX_LEN 8
|
||||
#define DM_UUID_PREFIX "CRYPT-"
|
||||
#define DM_UUID_PREFIX_LEN 6
|
||||
#define UUID_LEN 37 /* 36 + \0, libuuid ... */
|
||||
|
||||
static int dm_prepare_uuid(const char *type, const char *uuid, char *buf, size_t buflen)
|
||||
|
||||
Reference in New Issue
Block a user