From ffca561b2de43df0a9f7f9c0e717fca943f2c38b Mon Sep 17 00:00:00 2001
From: Johannes Holland <joh.ho@gmx.de>
Date: Tue, 20 Aug 2019 16:58:09 +0200
Subject: [PATCH] tctildr: fix segmentation fault if name_conf is too big
When strlen(name_conf) is too big and logging is set to at least DEBUG,
tctildr_conf_parse will cause a segmentation fault. This happens when
the unit tests are run with logging set to DEBUG. Hence, the logging
call has to be done after the check for strlen(name_conf).
Signed-off-by: Johannes Holland <joh.ho@gmx.de>
---
src/tss2-tcti/tctildr.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/tss2-tcti/tctildr.c b/src/tss2-tcti/tctildr.c
index 76248f358860..ff967317b57b 100644
--- a/src/tss2-tcti/tctildr.c
+++ b/src/tss2-tcti/tctildr.c
@@ -117,7 +117,6 @@ tctildr_conf_parse (const char *name_conf,
char *split;
size_t combined_length;
- LOG_DEBUG ("name_conf: \"%s\"", name_conf);
if (name_conf == NULL) {
LOG_ERROR ("'name_conf' param may NOT be NULL");
return TSS2_TCTI_RC_BAD_REFERENCE;
@@ -127,6 +126,8 @@ tctildr_conf_parse (const char *name_conf,
LOG_ERROR ("combined conf length must be between 0 and PATH_MAX");
return TSS2_TCTI_RC_BAD_VALUE;
}
+
+ LOG_DEBUG ("name_conf: \"%s\"", name_conf);
if (combined_length == 0)
return TSS2_RC_SUCCESS;
split = strchr (name_conf, ':');
--
2.27.0