gcc-9 complains that the string may be truncated when written into the output
structure. This shouldn't happen, but if it did, in principle we could remove a
different structure (with a matching name prefix). Let's just refuse the
operation if the name doesn't fit.
#if HAVE_LIBCRYPTSETUP
static int deferred_remove(DecryptedPartition *p) {
-
struct dm_ioctl dm = {
.version = {
DM_VERSION_MAJOR,
if (fd < 0)
return -errno;
+ if (strlen(p->name) > sizeof(dm.name))
+ return -ENAMETOOLONG;
+
strncpy(dm.name, p->name, sizeof(dm.name));
if (ioctl(fd, DM_DEV_REMOVE, &dm))