mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-11 10:50:01 +01:00
Fix a possible segfault in deferred deactivation.
For device without a type code shoud not try to use strcmp function. This can happen for example if deferref flag is used for device without proper DM-UUID where init_by_name does not set know device type. Thanks Clément Guérin for the report. Fixes: #910
This commit is contained in:
@@ -7081,12 +7081,15 @@ int crypt_convert(struct crypt_device *cd,
|
||||
/* Internal access function to header pointer */
|
||||
void *crypt_get_hdr(struct crypt_device *cd, const char *type)
|
||||
{
|
||||
assert(cd);
|
||||
assert(type);
|
||||
|
||||
/* One type can be OPAL */
|
||||
if (isLUKS2(type) && isLUKS2(cd->type))
|
||||
return &cd->u.luks2.hdr;
|
||||
|
||||
/* If requested type differs, ignore it */
|
||||
if (strcmp(cd->type, type))
|
||||
if (!cd->type || strcmp(cd->type, type))
|
||||
return NULL;
|
||||
|
||||
if (isPLAIN(cd->type))
|
||||
|
||||
@@ -868,6 +868,9 @@ else
|
||||
$CRYPTSETUP close $DEV_NAME2 >/dev/null 2>&1
|
||||
$CRYPTSETUP close $DEV_NAME >/dev/null 2>&1
|
||||
fi
|
||||
# Deferred remove of device without DM-UUID
|
||||
dmsetup create $DEV_NAME --table "0 8 crypt aes-xts-plain64 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 $LOOPDEV 0" || fail
|
||||
$CRYPTSETUP close --deferred $DEV_NAME || fail
|
||||
|
||||
# Interactive tests
|
||||
# Do not remove sleep 0.1 below, the password query flushes TTY buffer (so the code is racy).
|
||||
|
||||
Reference in New Issue
Block a user