mirror of
https://github.com/stefanberger/libtpms
synced 2026-08-07 08:20:20 +00:00
tpm2: Restrict profile names to 32 characters
Restrict profile names to 32 characters to avoid having to carry excessively long names in the TPM's state file. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
0d8377b1b4
commit
774cee962e
@ -65,6 +65,7 @@ const char defaultAlgorithmsProfile[] =
|
||||
|
||||
static const struct RuntimeProfileDesc {
|
||||
const char *name;
|
||||
#define MAX_PROFILE_NAME_LEN 32
|
||||
const char *prefix;
|
||||
size_t prefix_len;
|
||||
const char *commandsProfile;
|
||||
@ -339,8 +340,17 @@ RuntimeProfileGetNameFromJSON(const char *json,
|
||||
char **name)
|
||||
{
|
||||
const char *regex = "^\\{.*[[:space:]]*\"Name\"[[:space:]]*:[[:space:]]*\"([^\"]+)\".*\\}$";
|
||||
TPM_RC retVal;
|
||||
size_t len;
|
||||
|
||||
return RuntimeProfileGetFromJSON(json, regex, name, false);
|
||||
retVal = RuntimeProfileGetFromJSON(json, regex, name, false);
|
||||
if (!retVal) {
|
||||
len = strlen(*name);
|
||||
if (len > MAX_PROFILE_NAME_LEN)
|
||||
(*name)[MAX_PROFILE_NAME_LEN] = 0;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
static TPM_RC
|
||||
|
||||
Loading…
Reference in New Issue
Block a user