mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-14 12:20:00 +01:00
Fix a problem in integritysetup if a hash algorithm has dash in the name.
If users want to use blake2b/blake2s, the kernel algorithm name includes dash - like "blake2s-256". Because we use dash as a separator, this patch adds an exception for this case. Fixes: #581.
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "libcryptsetup.h"
|
||||
@@ -76,8 +77,10 @@ int crypt_parse_hash_integrity_mode(const char *s, char *integrity)
|
||||
return -EINVAL;
|
||||
|
||||
r = sscanf(s, "%" MAX_CIPHER_LEN_STR "[^-]-%" MAX_CIPHER_LEN_STR "s", mode, hash);
|
||||
if (r == 2)
|
||||
if (r == 2 && !isdigit(hash[0]))
|
||||
r = snprintf(integrity, MAX_CIPHER_LEN, "%s(%s)", mode, hash);
|
||||
else if (r == 2)
|
||||
r = snprintf(integrity, MAX_CIPHER_LEN, "%s-%s", mode, hash);
|
||||
else if (r == 1)
|
||||
r = snprintf(integrity, MAX_CIPHER_LEN, "%s", mode);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user