mirror of
https://github.com/stefanberger/libtpms
synced 2026-08-08 10:06:32 +00:00
tpm2: Add quote parameter to RuntimeCommandsPrint for optional quoting
Not all callers of RuntimeCommandsPrint will want to have the returned string use quotation marks at the beginning and end of the string. Therefore, add a quote parameter to this function that allows to avoid the quoting. Adapt the single caller to pass a quotation mark. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
c87ad14242
commit
837e618627
@ -431,14 +431,15 @@ RuntimeCommandPrint(char *buffer,
|
||||
|
||||
LIB_EXPORT char *
|
||||
RuntimeCommandsPrint(struct RuntimeCommands *RuntimeCommands,
|
||||
enum RuntimeCommandType rct)
|
||||
enum RuntimeCommandType rct,
|
||||
const char *quote)
|
||||
{
|
||||
COMMAND_INDEX commandIndex, commandCodeLo = 0, commandCodeHi = 0;
|
||||
char *buffer, *nbuffer = NULL;
|
||||
BOOL first = true, doPrint;
|
||||
int n;
|
||||
|
||||
buffer = strdup("\"");
|
||||
buffer = strdup(quote);
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
|
||||
@ -497,7 +498,7 @@ RuntimeCommandsPrint(struct RuntimeCommands *RuntimeCommands,
|
||||
if (commandCodeLo != 0)
|
||||
buffer = RuntimeCommandPrint(buffer, first, commandCodeLo, commandCodeHi);
|
||||
|
||||
n = asprintf(&nbuffer, "%s\"", buffer);
|
||||
n = asprintf(&nbuffer, "%s%s", buffer, quote);
|
||||
free(buffer);
|
||||
if (n < 0)
|
||||
return NULL;
|
||||
|
||||
@ -57,6 +57,7 @@ enum RuntimeCommandType {
|
||||
|
||||
char *
|
||||
RuntimeCommandsPrint(struct RuntimeCommands *RuntimeCommands,
|
||||
enum RuntimeCommandType rct);
|
||||
enum RuntimeCommandType rct,
|
||||
const char *quote);
|
||||
|
||||
#endif /* RUNTIME_COMMANDS_H */
|
||||
|
||||
@ -506,7 +506,8 @@ static char *TPM2_GetInfo(enum TPMLIB_InfoFlags flags)
|
||||
fmt = buffer;
|
||||
buffer = NULL;
|
||||
for (rct = RUNTIME_CMD_IMPLEMENTED; rct < RUNTIME_CMD_NUM; rct++) {
|
||||
runtimeCmds[rct] = RuntimeCommandsPrint(&g_RuntimeProfile.RuntimeCommands, rct);
|
||||
runtimeCmds[rct] = RuntimeCommandsPrint(&g_RuntimeProfile.RuntimeCommands, rct,
|
||||
"\"");
|
||||
if (!runtimeCmds[rct])
|
||||
goto error;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user